rbv_api.parseXML()

Purpose

Parses an XML string and returns an instance of org.w3c.dom.Element corresponding to the XML root. JavaScript can use all methods of this Java object. See http://www.w3.org/2003/01/dom2-javadoc/org/w3c/dom/Element.html for more info.

Syntax

rbv_api.parseXML(xmlString)

Parameters

xmlString

An XML document as a string

Return value

Root element of an XML document

Example

var xml = "<a><b>BBB</b><c>CCC</c></a>";
var root = rbv_api.parseXML(xml);
var nodes = root.getChildNodes();
    for (var k=0; k<nodes.length; k++) {
      var child = nodes.item(k);
      rbv_api.println("Tag="+child.getTagName());
      var nodes2 = child.getChildNodes();
      for (var n=0; n<nodes2.length; n++) {
      var child2 = nodes2.item(n);
      var x = child2.getNodeValue();
      rbv_api.println("Value="+x);
       }
     }
      
Output:
Tag=b
Value=BBB
Tag=c
Value=CCC
Note: When on Java 17, make sure to incorporate the following necessary JAVA_OPTS in the setenv.bat/sh file for specific packages:
  • For DOM-related issues, include the following line:

    JAVA_OPTS=%JAVA_OPTS% --add-exports=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED

  • For DTM reference-related issues, insert the following line:

    JAVA_OPTS=%JAVA_OPTS% --add-exports=java.xml/com.sun.org.apache.xml.internal.dtm.ref=ALL-UNNAMED

Any changes made in setenv.bat does require restarting the instance to apply the modifications.

Likewise, in certain scenarios, even after adding the configurations to setenv.bat/sh, you may need to include the class in the CustomClassFilter shared property. This is essential for white labelling purposes, ensuring access via Rhino.