Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading XML in a VB Application

Status
Not open for further replies.

GDX

Programmer
Jun 4, 2000
186
0
0
US
Lets say i have an xml page setup...

<book>Mybook</book>
<price>$5</price>

how do i go about &quot;reading&quot; this information into a visual basic application? basically what i want to do is have the clients use the application and read the xml page, so when i add more information all they have to do is run the application :)

Thanking you in advance,
Gordon R. Durgha

Gordon R. Durgha
gd@vslink.net
 
Gordon,

Try posting this question in a Visual Basic forum.

Good luck
-pete
 
I don't know if you've already figured this out, but if not:

You need to reference the project to the MSXML parser. Then you need to create an XMLDomDocument object, and parse the file into it. If you need specifics on this, feel free to email me, and I can help you out.

shepherd
 
Try this out..may be it could be of help...even i am new to xml and trying out stuff right now.....might get some help....


Dim a As New DOMDocument
a.loadXML (xmlfile)
x = a.documentElement.childNodes.length

'for loop for traversing the xml tags
For i = 0 To x - 1
MsgBox a.documentElement.childNodes.Item(i).nodeName
val1 = IIf(IsNull(a.documentElement.childNodes.Item(i).nodeValue), &quot;no value&quot;, a.documentElement.childNodes.Item(i).nodeValue)

MsgBox val1

If a.documentElement.childNodes.Item(i).childNodes.nextNode.hasChildNodes Then

For w = 0 To (a.documentElement.childNodes.Item(i).childNodes.length - 1)

MsgBox a.documentElement.childNodes.Item(i).childNodes.Item(w).baseName

MsgBox a.documentElement.childNodes.Item(i).childNodes.Item(w).Text

Next
End If
Next

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top