I am having an app that gets an xml stream continuosly and then use it to process some information. So far i had only one name space for all the streams and i did it easily as
doc = new XPathDocument(ds + "/probe");
navigator = doc.CreateNavigator();
ns = new XmlNamespaceManager(navigator.NameTable);
ns.AddNamespace("m", "urn:namsp.org:namSpDev:1.1");
nodes = navigator.Select("//m:DataItem", ns);
while (nodes.MoveNext())
{
node = nodes.Current;
}
But now i have a problem. THere is another stream that has the namespace
"urn:namsp.org:namSpDev:1.2"
So in my application i have to check the stream and see which namespace it is and then only i can add the app name space using
ns.AddNamespace("m", "urn:namsp.org:namSpDev:1.1");
How should i do this?
I tried converting the doc.toString() and used .contains() to check if any one of this passes but it doesnt work.
What i finally did is retrieved the xml stream and converted into a string. Then using
I splitted the tag and used the tag identifier to get the value of the name space. This works for me as there will not be much difference in the name spaces in the stream that i use.