T
Trace C
I have XML that has XML embedded in it, which has a namespace on the
root element I am trying to get, so I end up with XML of:
<ApplicationsList xmlns="urn:sp-schema">
<Application>
<Name></Name>
<ApplicationAddress></ApplicationAddress>
<FormAddress></FormAddress>
<Description></Description>
</Application>
<Application>
<Name></Name>
<ApplicationAddress></ApplicationAddress>
<FormAddress></FormAddress>
<Description>EA3000</Description>
<ImageIndex>0</ImageIndex>
.....
So I load this XML into a DOM, using LoadXml
appListDoc.LoadXml(xmlNode.OuterXml);
//Create the XmlNamespaceManager.
XmlNamespaceManager nsmgr = new
XmlNamespaceManager(appListDoc.NameTable);
nsmgr.AddNamespace("", "urn:sp-schema");
foreach (XmlNode appNode in
appListDoc.DocumentElement.SelectNodes("Application", nsmgr))
{
// do stuff
}
In my foreach loop, it never finds the "Application" element. But if
I iterate through the childNodes, all is fine - but I don't want to do
this.
======= Immediate Window ================
appListDoc.DocumentElement.ChildNodes
{System.Xml.XmlChildNodes}
[System.Xml.XmlChildNodes]: {System.Xml.XmlChildNodes}
System.Object: {System.Xml.XmlChildNodes}
Count: 16
ItemOf: <cannot view indexed property>
=========================================
Please could someone help!
Thanks,
Trace
root element I am trying to get, so I end up with XML of:
<ApplicationsList xmlns="urn:sp-schema">
<Application>
<Name></Name>
<ApplicationAddress></ApplicationAddress>
<FormAddress></FormAddress>
<Description></Description>
</Application>
<Application>
<Name></Name>
<ApplicationAddress></ApplicationAddress>
<FormAddress></FormAddress>
<Description>EA3000</Description>
<ImageIndex>0</ImageIndex>
.....
So I load this XML into a DOM, using LoadXml
appListDoc.LoadXml(xmlNode.OuterXml);
//Create the XmlNamespaceManager.
XmlNamespaceManager nsmgr = new
XmlNamespaceManager(appListDoc.NameTable);
nsmgr.AddNamespace("", "urn:sp-schema");
foreach (XmlNode appNode in
appListDoc.DocumentElement.SelectNodes("Application", nsmgr))
{
// do stuff
}
In my foreach loop, it never finds the "Application" element. But if
I iterate through the childNodes, all is fine - but I don't want to do
this.
======= Immediate Window ================
appListDoc.DocumentElement.ChildNodes
{System.Xml.XmlChildNodes}
[System.Xml.XmlChildNodes]: {System.Xml.XmlChildNodes}
System.Object: {System.Xml.XmlChildNodes}
Count: 16
ItemOf: <cannot view indexed property>
=========================================
Please could someone help!
Thanks,
Trace