Re: Getting namespace info from a parsed XML file
[email protected] Thu, 01 May 2014 09:26:11 -0700
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Organization | Oracle Corporation |
| Message-ID | <[email protected]> |
use the cursor api. it will give you all the namespaces in scope in a
Map object.
XmlObject xobj = XmlObject.Factory.parse(xml);
XmlCursor curs = xobj.newCursor();
curs.toFirstChild();
HashMap map = new HashMap();
curs.getAllNamespaces(map);
On 5/1/2014 7:31 AM, jgagnon wrote:
> I'm trying to figure out how to get the namespace information (the
> namespace(s) itself and the namespace prefix(es) that are applied to
> elements within the document) contained within an XML file after I have
> parsed it in XMLBeans. For example, consider the following XML snippet:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <pfx:DoorCommand xsi:schemaLocation="http://www.domain.org/ ../schema.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:pfx="http://www.domain.org/">
> <pfx:MessageHeader>
> <pfx:SystemID>
> <pfx:UUID>
> 4142434445464748494a4b4c4d4e4f50
>
> </pfx:UUID>
> <pfx:DescriptiveLabel>This document is
> UNCLASSIFIED</pfx:DescriptiveLabel>
> </pfx:SystemID>
> ...
> </pfx:DoorCommand>
>
> In the case, the namespace I'm concerned with is "http://www.domain.org" and
> the prefix "pfx" that's applied to the document elements.
>
> I have not been able to figure out how to do this via the XMLBeans API.
>
>
>
> --
> View this message in context: http://xmlbeans.996285.n3.nabble.com/Getting-namespace-info-from-a-parsed-XML-file-tp7498.html
> Sent from the XMLBeans User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>