I'm having a bit of trouble parsing an xml file with a namespace
the xml file has a line like this
<my:include href="include/myfile.xml"/>
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(file);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("my", "http://www.w3.org/2001/xinclude");
XmlNodeList includeNodeList = xmlDoc.SelectNodes(@"/root/my:include", nsmgr);
I'm used to doing somthing like this but this is not reading how i think it should.. node["href"] is null and no matter what i seem to change cant get
foreach (XmlNode node in includeNodeList)
{
if (node["href"] != null)
{
// Save node["href"].Value here
}
}
If i stop it in the debugger i can see node has the info i want in the Outertext. .. i can save outer text and parse it this way but i know there has to be something simple i'm overlooking. Can someone tell me what i need to do to get href value please.
xmlnsis declared?