XPath to get namespace of root node



Given the following xml snippets:



<ns2:Invoice xmlns="http://ift.tt/1tYqNLC" xmlns:ns2="http://namespace2.com"
xmlns:ns3="http://namespace3.com">
.........
</ns2:Invoice>


and:



<ns3:Invoice xmlns="http://ift.tt/1tYqNLC" xmlns:ns2="http://namespace2.com"
xmlns:ns3="http://namespace3.com">
.........
</ns3:Invoice>


Can xpath be used to get the namespace associated with the root () element?


Expected results would be as follows: In the first example, the root is prefixed "ns2" so I would expect "http://namespace2.com" In the second example, the root is prefixed "ns3" so I would expect "http://namespace3.com"


No comments:

Post a Comment