Java XPath Create getXPath()

Here you can find the source of getXPath()

Description

Gets the XPath API, creating it if necessary.

License

Open Source License

Return

the XPath API.

Declaration

public static synchronized XPath getXPath() 

Method Source Code

//package com.java2s;

import javax.xml.xpath.XPath;

import javax.xml.xpath.XPathFactory;

public class Main {
    /** Reusable XPath factory. */
    private static XPathFactory xpathFactory;
    /** Reusable XPath. */
    private static XPath xpath;

    /**/* w ww . jav  a2 s  .  co  m*/
     * Gets the XPath API, creating it if necessary.
     * 
     * @return the XPath API.
     */
    public static synchronized XPath getXPath() {
        if (xpath == null) {
            xpath = getXPathFactory().newXPath();
        }
        return xpath;
    }

    /**
     * Gets the XPath factory, creating it if necessary.
     * 
     * @return the XPath factory.
     */
    public static synchronized XPathFactory getXPathFactory() {
        if (xpathFactory == null) {
            xpathFactory = XPathFactory.newInstance();
        }
        return xpathFactory;
    }
}

Related

  1. getXmlString(Node inXml, String xpath)
  2. getXpath()
  3. getXPath()
  4. getxPath()
  5. getXPath()
  6. getXPath()