Tuesday, December 1, 2009

MSXML2.DOMDocument.selectNodes vs. XDocument.Descendants

OLD MSXML way:
MSXML2.DOMDocument xmlDoc = new MSXML2.DOMDocument();
MSXML2.IXMLDOMNodeList xmlList = xmlDoc.documentElement.selectNodes("//MyNodeName”);
 
LINQ way:
XDocument xDoc = XDocument.Parse(batchXML);
IEnumerable<XElement> commands = xDoc.Descendants(XName.Get(“MyNodeName”));

contactID = contactEl.Attribute("conactID").Value;
name = contactEl.Element("FirstName").Value;

1 comments:

lee woo said...

If you're a good person, the goodness will continue through your
descendants. See the link below for more info.

#descendants
www.ufgop.org

Post a Comment