1

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.

swordfish
  • 4,899
  • 5
  • 33
  • 61

2 Answers2

1

These links may be useful:

Detecting Xml namespace fast

Parsing XML with elements containing colon / namespace

How to Select XML Nodes with XML Namespaces from an XmlDocument?

Community
  • 1
  • 1
Mamta D
  • 6,310
  • 3
  • 27
  • 41
  • i already checked all these. If u look at my question its certainly different. I also found out a workaround even though its not an optimal solution. – swordfish May 20 '11 at 07:55
0

What i finally did is retrieved the xml stream and converted into a string. Then using

string.contains("xmlns")

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.

swordfish
  • 4,899
  • 5
  • 33
  • 61