Parse XML file to get all Namespace information

Cruvenium

New Member
I want to be able to get all namespace information from a given XML File.So for example, if the input XML File is something like:\[code\]<ns1:create xmlns:ns1="http://predic8.com/wsdl/material/ArticleService/1/"> <ns1:article xmlns:ns1="xmlns:ns1='http://predic8.com/material/1/"> <ns1:id>1</ns1:id> <description>bar</description> <name>foo</name> <ns1:price> <amount>00.00</amount> <currency>USD</currency> </ns1:price> <ns1:price> <amount>11.11</amount> <currency>AUD</currency> </ns1:price> </ns1:article> <ns1:article xmlns:ns1="xmlns:ns1='http://predic8.com/material/1/"> <ns1:id>2</ns1:id> <description>some name</description> <name>some description</name> <ns1:price> <amount>00.01</amount> <currency>USD</currency> </ns1:price> </ns1:article></ns1:create>\[/code\]I would like to expect an output that looks something like this (in this case comma-separated):\[code\]create, ns1, http://predic8.com/wsdl/material/ArticleService/1/article, ns1, http://predic8.com/material/1/price, ns1, http://predic8.com/material/1/id, ns1, http://predic8.com/material/1/\[/code\]Important notes:It is important that we also consider sub-nodes which are defined within a specific namespace, but whose definition may be defined at a higher node. For example, we would still like to pick up the node \[code\]ns1:id\[/code\], where we need to trace back to the parent node \[code\]ns1:article\[/code\] to discover that the namespace url is \[code\]xmlns:ns1='http://predic8.com/material/1/\[/code\] I am implementing in Java, so I would not mind either a Java-based solution, or even a XSLT-based solution might seem appropriate.
 
Back
Top