<root xmlns="nameSpace">
<county>
<group name="Sutter">
<group name="Yuba">
<group name="Placer">
</group>
</group>
<root>
-----------------------------------------------------------
//C#
XDocument xDoc = XDocument.Load("Country.xml");
XNamespace ns = xDoc.Root.Name.Namespace;
//adding the namespace infront of the XName will allow you to access the node.
var elements = xDoc..Element(ns+"root").Element(ns+"County").Descendants(ns+"Group");
foreach (var element in elements)
{
Console.Write(element.Attribute("name").ToString());
}
No comments:
Post a Comment