I have the following XML example:
<?xml version="1.0" encoding="UTF-8"?> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:custom="http://example.com/opensearchextensions/1.0/"> <ShortName>Test</ShortName> <Description>Testing....</Description> <Url template="whatever" type="what" /> <Query custom:color="blue" role="example" /> </OpenSearchDescription>
I am concerned about the Query
element. It has a namespace attribute and in java you need namespaceURI
to get the value.
My question is: how do I get a list of namespaces from the root element (in this case, the OpenSearchDescription
element)? I need the attribute, prefix, and namespace URI that I can use to query Query
.
Thanks.
PS: I use the DOM in Java, standard in Java SE. I am ready to move to XPath, if possible. The requirement is that you only use the Java Standard API.
Buhake sindi
source share