Helper method to retrieve XML {@link Node} with provided xPath.
@param parsedXml - a {@link Document} object with parsed XML content
@param path - the xPath expression to retrieve the value with
@return XML {@link Node} object
@since 2.1.0
975671
public static Node nodeFromXPath(Document parsedXml, String path) {
		XPath xPath = XPathFactory.newInstance().newXPath();
		try {
			return (Node) xPath.evaluate(path, parsedXml.getDocumentElement(),
					XPathConstants.NODE);
		}
		catch (XPathExpressionException exception) {
			LOG.error("Incorrect xpath provided: " + path, exception);
			throw new IllegalArgumentException();
		}
	}
402636
@Override
    public Node get(final String path) throws IllegalArgumentException {
        // Precondition checks
        Validate.notNullOrEmpty(path, "No path was specified");

        // Make a Path
        final ArchivePath realPath = new BasicPath(path);

        // Delegate
        return get(realPath);
    }
8419
def get_node(path, create = false)
      n = @root
      path.sub(%r{^/}, "").split("/").each do |elem|
        if !(n[elem])
          return nil if !create
          n[elem] = Node.new(elem)
        end
        n = n[elem]
      end
      if n.nil?
        DBus.logger.debug "Warning, unknown object #{path}"
      end
      n
    end
759858
def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'pathLst'
          node_child.xpath('a:path', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').each do |path_node|
            @paths_list << DocxShapeLinePath.new(parent: self).parse(path_node)
          end
        end
      end
      self
    end
287232
public static void xmlClassInexistent(String path, Class<?> aClass){
		throw new XmlMappingClassDoesNotExistException (MSG.INSTANCE.message(xmlMappingClassDoesNotExistException1,path,aClass.getSimpleName()));
	}
754784
@SuppressWarnings("rawtypes")
	public List<NodeConfig> parserByXpath(InputStreamReader xml, String xpath) throws UnmarshalException {
		
		List<NodeConfig> nodeConfigList = new ArrayList<NodeConfig>();
		SAXBuilder builder = new SAXBuilder(false);
		Document doc = null;
		
		try {
			doc = builder.build(xml);
			Element root = doc.getRootElement();
			
			if (xpath != null && !xpath.equals("")) {
				List selectNodes = XPath.selectNodes(root, xpath);
				for (Iterator iterNode = selectNodes.iterator(); iterNode.hasNext();) {
					NodeConfig nodeConfig = parserNode((Element) iterNode.next());
					nodeConfigList.add(nodeConfig);
				}
			}
			
			return nodeConfigList;
		} catch (JDOMException e) {
			throw new UnmarshalException(e);
		} catch (IOException e) {
			throw new UnmarshalException(e);
		}

	}
215038
def get_element_by_path(tree, path_and_name, namespace):
    # type: (_Element, str, str) -> typing.Union[_Element, None]
    """"""
    global xml_element_cache
    namespace_map = {'A': namespace[1:-1]}
    base_path, element_name = path_and_name.rsplit('/', 1)
    if base_path in xml_element_cache:
        base_element = xml_element_cache[base_path]
    else:
        base_xpath = ar_path_to_x_path(base_path)
        elems = tree.xpath(base_xpath, namespaces=namespace_map)
        base_element = elems[0] if elems else None
        xml_element_cache[base_path] = base_element

    element_found = None
    if base_element is not None:
        element_found = base_element.xpath(
            ".//A:SHORT-NAME[text()='{name}']/..".format(name=element_name),
            namespaces=namespace_map)[0]
    return element_found
1237112
def _parse(cls, xml_path):
    
    try:
      parsed_xml = parse(xml_path)
    # Minidom is a frontend for various parsers, only Exception covers ill-formed .xml for them all.
    except Exception as e:
      raise cls.XmlError('Error parsing xml file at {0}: {1}'.format(xml_path, e))
    return parsed_xml
669047
public static Node getElement(Node node, String xExpr, XPath xPath) throws XPathExpressionException {
        return (Node) xPath.compile(xExpr).evaluate(node, XPathConstants.NODE);
    }
440956
private Xml getNode(String... path)
    {
        Xml node = root;
        for (final String element : path)
        {
            try
            {
                node = node.getChild(element);
            }
            catch (final LionEngineException exception)
            {
                throw new LionEngineException(exception, media);
            }
        }
        return node;
    }
1216178
@SuppressWarnings("unchecked")
	public TreeNode<T> findByPath(T... path) {
		return findByPath(Arrays.asList(path));
	}
1306652
function xPath(xPathString) {
    var xResult = document.evaluate(xPathString, document, null, 0, null);
    var xNodes = [];
    var xRes = xResult.iterateNext();
    while (xRes) {
        xNodes.push(xRes);
        xRes = xResult.iterateNext();
    }

    return xNodes;
}
573366
@Pure
	public static Document parseXML(String xmlString) {
		assert xmlString != null : AssertMessages.notNullParameter(0);
		try {
			return readXML(new StringReader(xmlString));
		} catch (Exception e) {
			//
		}
		return null;
	}
573241
public final boolean hasNode(String... path)
    {
        Xml node = root;
        for (final String element : path)
        {
            if (!node.hasChild(element))
            {
                return false;
            }
            node = node.getChild(element);
        }
        return true;
    }
485163
public static function xpath(DOMDocument $dom, $path) {
    $xpath = new DOMXPath($dom);
    
    $ret = array();
    foreach ($xpath->query($path) as $node) {
      $ret[] = $node;
    }
    return $ret;
  }
1008828
public function evaluate( $path, $node = NULL )
	{
		if( !$this->xPath )
			throw new Exception( 'No XML loaded yet.' );
		if( $node )
			$nodeList	= $this->xPath->evaluate( $path, $node );
		else
			$nodeList	= $this->xPath->evaluate( $path );
		return $nodeList;
	}
300763
@Override
    public List<Node> parse(String xml) throws ParseException {
        try {
            final SAXParserFactory factory = SAXParserFactory.newInstance();
            final SAXParser saxParser = factory.newSAXParser();
            final NodeXmlHandler handler = new NodeXmlHandler();

            saxParser.parse(new CharSequenceInputStream(xml, Charset.defaultCharset()), handler);

            return handler.getNodes();
        } catch (IOException ioe) {
            throw new ParseException(ioe);
        } catch (SAXException e) {
            throw new ParseException(e);
        } catch (ParserConfigurationException e) {
            throw new ParseException(e);
        }
    }