By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

need some XML help

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Mike" schrieb
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/XPathTutoria.../examples.html

Cheers

Arne Janning
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.