Framework Madness!

And other adventures C# and asp.net …

Archive for March 7th, 2009

XElement and XPath: Covalent Bonding

leave a comment »

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!

Written by Lynn Eriksen

March 7, 2009 at 2:48 am

Posted in Uncategorized

Tagged with