Geeks With Blogs

Lance's TextBox
Andrew Mooney just showed me the SelectSingleNode function of the XmlDocument class, which I'd previously overlooked for some reason. Doh!

In searching for a node in an XmlDocument class with a particular attribute value, I was stepping through the entire tree! Instead, it is much easier to simply use:

Dim place as System.Xml.XmlNode
place = Msgs.SelectSingleNode("/myroot/myitem[@myattribute = '" + myvalue + "']")
Posted on Wednesday, June 22, 2005 3:52 PM Programming | Back to top


Comments on this post: XmlDocument.SelectSingleNode

# re: XmlDocument.SelectSingleNode
Requesting Gravatar...
if i change myvalue to Myvalue then its not returning the correct result, pls help me
Left by Manas on Mar 14, 2007 5:18 AM

# re: XmlDocument.SelectSingleNode
Requesting Gravatar...
nice, thanks. that helps me.
Left by vcllvc on Mar 15, 2007 10:27 AM

# re: XmlDocument.SelectSingleNode
Requesting Gravatar...
Very helpful for me
timely help
Left by sathish on Jun 26, 2007 7:34 AM

# re: XmlDocument.SelectSingleNode
Requesting Gravatar...
thanks for a great tip. Is it possible to use a similar syntax for multiple attributes? e.g. how would you grab

<issue year="2007" month="4">

Left by nightsky on Oct 31, 2007 10:05 AM

# re: XmlDocument.SelectSingleNode
Requesting Gravatar...
Man. Thanks a lot !!!
Whew... drove me nuts before I found your example.
Left by Vlad on Jun 10, 2008 7:38 PM

# re: XmlDocument.SelectSingleNode
Requesting Gravatar...
Dim place as System.Xml.XmlNode;
place = Msgs.SelectSingleNode("/myroot/myitem[@myattribute = '" + myvalue + "' and @myAnotherattribute ='" + myanothervalue + "']")
Left by ET on Jan 20, 2009 5:11 AM

Your comment:
 (will show your gravatar)


Copyright © Lance Robinson | Powered by: GeeksWithBlogs.net