SeanInSeattle wrote:
Ah, yes. I appreciate that. Though, which one is the URI in my example xml?
Is it the p1:schemalocation value altogether, or just the "http://[...]", or
is it the xmlns:p1 value?
Well the code I suggested simply takes the URI from the DocumentElement,
that is why I suggested to use
mgr.AddNamespace("df", doc.DocumentElement.NamespaceURI);
where "df" is a prefix you can freely choose and where the second
argument simply reads out the NamespaceURI from the DocumentElement. In
the sample you posted that URI is "Data_Feed" so assuming that is how
your real XML looks you could also use
mgr.AddNamespace("df", "Data_Feed");
but the code I posted works perfectly even when the XML changes while
the last suggestion would hard code the URI in the C#.
Here's my code:
[code]
try {
XmlDocument xDoc = new XmlDocument();
xDoc.Load(XMLDoc_URL);
System.Xml.XmlNamespaceManager xmlnsManager = new
System.Xml.XmlNamespaceManager(xDoc.NameTable);
xmlnsManager.AddNamespace(strDataFeedName, xDoc.DocumentElement.NamespaceURI);
Without seeing the value of strDataFeedName
foreach (System.Xml.XmlNode xnDetail in
xDoc.DocumentElement.SelectNodes(XPathToData, xmlnsManager))
and XPathToData it is not possible to tell whether your code works.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/