xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerry...@oracle.com
Subject Re: Getting namespace info from a parsed XML file
Date Thu, 01 May 2014 16:26:11 GMT
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: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Mime
View raw message