View Single Post
Old 07-19-2019, 08:25 PM   #4
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,584
Thanks: 68
Thanked 2,755 Times in 2,639 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: displaying data from an xml file on a form

first read the file content to a variable string.
then find the tag <raw_text> save its position on the string.
next find </raw_text>, save it's position on the string.
then using mid() function extract the string within.
split the string you extracted and put it to your
textbox:
Code:
Dim objFSO As Object 		'Scripting.FileSystemObject
Dim objText As As Object 	'Scripting.TextStream
Dim strContent As String
Dim Pos1 As Integer
Dim Pos2 As Integer
Dim var As Variant

Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objText = objFSO.OpenTextFile("D:\theXMLFileHere.xml", ForReading)
strContent = objText.ReadAll()
Pos1=Instr(1, strContent, "<raw_text>")
If Pos1 <> 0 Then
	Pos1=Pos1 + Len("<raw_text>")
	Pos2 = Instr(Pos1, strContent, "</raw_text>")
	If Pos2 <> 0 Then
		strContent = Mid(strContent, Pos1, Pos2 - Pos1)
		While Instr(strContent, "  ")
			strContent = Replace(strContent, "  ", " ")
		Wend
		var = Split(strContent, " ")
		[YourTextbox1] = var(0)
		[YourTextbox2] = var(1)
		[YourTextbox3] = var(3)
		...
		...
	End If
End If
Set ObjText=Nothing
Set ObjFSO = Nothing
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
The Following User Says Thank You to arnelgp For This Useful Post:
duke217 (08-21-2019)