Parsea a text as a XML document and returns the root element (org.w3c.dom.Element). It is the first step to obtain
an element with which to work and be able to apply the DOM functions.
1 dom.parse
<dom.parse>
<text /> !
</dom.parse>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Etext | String |
Returns | |
---|---|
Type | Description |
org.w3c.dom.Element | Root element of the XML document. |
Exceptions
IOException
The text could not be obtained.
org.xml.sax.SAXException
Error of parse, the document does not contain a well-formed text.
javax.xml.parsers.ParserConfigurationException
Error of parse, the document does not contain a well-formed text.
Example
Parsear a file which contains a XML document and get the root element.
Copy
<xsql-script name='dom_parse'> <body> <set name='root'> <dom.parse> <file name='f1.xml' type='absolute' /> </dom.parse> </set> <println><root/></println> </body> </xsql-script>
Example
Go through an XML from a variable with XML content.
Copy
<xsql-script name='dom_parse'> <body> <set name='m_xml'><document> <element>hello</element> <element>world</element> </document> </set> <set name='hl7_root'> <dom.parse><m_xml /></dom.parse> </set> <set name='m_domnode'> <dom.element.getFirstChildElement> <hl7_root /> </dom.element.getFirstChildElement> </set> <while> <expr><isnotnull><m_domnode/></isnotnull></expr> <do> <if> <expr> <not><dom.node.isTextNode><m_domnode/></dom.node.isTextNode></not> <!-- the blanks which are also elements are discarded --> </expr> <then> <set name='m_cabnodename'><dom.node.getNodeName><m_domnode/></dom.node.getNodeName></set> <set name='m_cabnodevalue'><dom.node.getChildCharacterData><m_domnode/></dom.node.getChildCharacterData></set> <println><m_cabnodename/></println> </then> </if> <set name='m_domnode'><dom.node.getNextSibling><m_domnode/></dom.node.getNextSibling></set> </do> </while> </body> </xsql-script>