Selecting nodes with XPath API
In the previous section, XML document nodes were selected automatically with the XPath Search tool in JDeveloper. In this section, we shall select nodes with the XPath API in the XPathParser class. JDeveloper XPath searches with the XPath Search tool are for the convenience of the developer as they find nodes faster than when looking through the XML file. The XPath searches, using the XPath API, actually let your application find nodes via XPath.
The XMLDocument
class has select
methods to select nodes with an XPath expression. A single node may be selected or a NodeList
of nodes may be selected. Nodes declared in a namespace may also be selected. First, we need to import the oracle.xml.parser.v2
package that has the XMLDocument
class and the parser class DOMParser
, from which an XMLDocument
may be obtained.
import oracle.xml.parser.v2.*;
Creating the DOM parser
Next, we need to parse an XML document and create a DOM structure for the XML document before being...