need some XML help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an xml file such as
<cars>
<make selected=true>BMW</make>
<model>325 Ci</model>
</cars>

I can I read and get
<make selected=true> ?

I want to show it on the screen only if selected = true.
I can get all of them, but I can't check for the selected value
 
I have an xml file such as
<cars>
<make selected=true>BMW</make>
<model>325 Ci</model>
</cars>

I can I read and get
<make selected=true> ?

I want to show it on the screen only if selected = true.
I can get all of them, but I can't check for the selected value

Hi Mike,

use XPath:

Dim doc As XmlDocument = New XmlDocument
doc.LoadXml("<cars><make selected=""true"">BMW</make><model>325
Ci</model></cars>")
Dim nc As XmlNodeList = doc.SelectNodes("/cars/make[@selected='true']")
For Each n As XmlNode In nc
Debug.WriteLine(n.InnerXml)
Next


Have a look at the XPath-Tutorial, if you are not familiar with XPath:
http://www.zvon.org/xxl/XPathTutorial/General/examples.html

Cheers

Arne Janning
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top