Get all namespace prefix from XmlDocument class

J

John Lee

Hi,

if I have xml document
<root xmlns:a="myNS1" xmlns:b="myNS2" xmlns="myNS">
<a:node1>value1</a:node1>
<b:node2>value2</b:node2>
<node3>value3</node3>
</root>

if I load the above xml in XmlDocument, I can get the namespaceURI "myNS1"
usnig .GetNamespaceOfPrefix("a")

Could someone tell me how to get/enumerate all namespace prefixes and
namespaceURIs?

Thanks very much!
John
 
K

Kevin Yu [MSFT]

Hi John,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to enumerate all namespace
prefixes and URIs in an XmlDocument. If there is any misunderstanding,
please feel free to let me know.

As far as I know, there are no methods or properties in XmlDocument for us
to get all the namespaces in an Xml. However, here is an article using XSL
to search for all namespaces in an Xml.

http://www.xmleverywhere.com/wrox/2270/2270_05_02.htm

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top