huckfinn19
Programmer
Hi! I am just trying to get the XML namespace value out of my XML file, but can't seem to get it to work! Anyone can help me?
Here's a sample XML file:
<?xml version="1.0" encoding="utf-8" ?>
<pages xmlns="the_namespace_value_i_want">
<value>5</value>
</pages>
I want to get the value of the xmlns. I tried the following code, but I get values I am not interested in:
I get:
-----------
Prefix=xml, Namespace=Prefix=xmlns, Namespace=Prefix=, Namespace=
-----------
Anyone can help me?
Thanks!
Huck
Here's a sample XML file:
<?xml version="1.0" encoding="utf-8" ?>
<pages xmlns="the_namespace_value_i_want">
<value>5</value>
</pages>
I want to get the value of the xmlns. I tried the following code, but I get values I am not interested in:
Code:
XmlTextReader tr = new XmlTextReader(@"simple.xml");
XmlNamespaceManager nsm = new XmlNamespaceManager(tr.NameTable);
do{
foreach (String prefix in nsm) {
Console.WriteLine("Prefix={0}, Namespace={1}", prefix,nsm.LookupNamespace(prefix));
}
}
while (nsm.PopScope());
I get:
-----------
Prefix=xml, Namespace=Prefix=xmlns, Namespace=Prefix=, Namespace=
-----------
Anyone can help me?
Thanks!
Huck