473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

get list of used namespaces

Hi all,
I load an xml file into XmlDocument object and would like to get a list
of namespaces used in the file. How can I get a list of namespaces used in
xml file?

Thanks.
Nov 12 '05 #1
1 1748


helpful sql wrote:

I load an xml file into XmlDocument object and would like to get a list
of namespaces used in the file. How can I get a list of namespaces used in
xml file?


XPath has a namespace axis for namespace nodes which are in scope for a
given element node, here is an example using an XPath expression with
SelectNodes to output all namespace nodes (those explictly given and
those implictly defined):

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"test2005052501.xml");
XmlNodeList namespaceNodes =
xmlDocument.SelectNodes("//*/namespace::*");
foreach (XmlNode node in namespaceNodes) {
Console.WriteLine(
"Node type {0} has name \"{1}\" and value \"{2}\".",
node.NodeType, node.Name, node.Value);
}

Note that you will get a lot of duplicates that way so you would need to
filter that list further to remove duplicates.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Zorro | last post by:
For almost a decade now some desirable features have appeared in circulations as C++ wish list. Consider the following features. Invariants and Contracts. Extending enumerations. Namespaces...
1
by: Guy | last post by:
Hi, I have an XML file which its content can't be altered as a source. My solution should be able to produce some kind of pointers (in a seperate file) to specific nodes (or even...
3
by: Lee Alexander | last post by:
I want to find out all the namespaces for an assembly and convert them into a tree that I can then traverse for use in an autocomplete popup. Now I figure I can do it by running over all the...
3
by: sundew | last post by:
so here is the test case: <head> <script type='text/javascript'> // this function simply returns the number of enumerable namespaces(objects) function numNSpaces(){ var num = 0; for(var i in...
77
by: Ville Vainio | last post by:
I tried to clear a list today (which I do rather rarely, considering that just doing l = works most of the time) and was shocked, SHOCKED to notice that there is no clear() method. Dicts have it,...
6
by: Lonnie Princehouse | last post by:
List comprehensions appear to store their temporary result in a variable named "_" (or presumably "_", "_" etc for nested comprehensions) In other words, there are variables being put into the...
30
by: Pep | last post by:
Is it best to include the code "using namespace std;" in the source or should each keyword in the std namespace be qualified by the namespace tag, such as std::cout << "using std namespace" <<...
10
by: John Salerno | last post by:
If I want to have a list like this: where the first part of each tuple is a variable name and the second part is a label for the user to see, such as a form like this: First Name: ________...
3
by: ramhog | last post by:
I see exceptions in lots of different namespaces. Is there a complete list somewhere of all the exceptions from all the different namespaces? Thanks.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.