Archive for March 7th, 2009
Yes. It’s true. You can use XElement and XPath together.
I was working on an applet today using XElement and was having a hard time getting at nested elements. I kept searching the XElement members in VS intellisense but couldn’t get anything that even hinted at XPath like support. Well a trip to the XElement members documentation enlightened me. (http://msdn.microsoft.com/en-us/library/system.xml.linq.xelement_members.aspx) It looks like if you import the System.Xml.XPath name space you get full XPath support for returning single or multiple XElement vis-à-vis extension methods. That makes things SO much easier working with XElements. Saved a TON of time!