“Holen Sie sich DOM -Knoten mit XPath” Code-Antworten

Holen Sie sich DOM -Knoten mit XPath

function getElementByXpath(path) {
  return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

// *** use *** 
// getElementByXpath(XpathTargetingDOMNode)
S4N705H

XPath Nodejs

const xpath = require("xpath-html");
const node = xpath.fromPageSource(html).findElement("//*[contains(text(), 'with love')]");
// There is a library xpath-html that can help you using XPath to query HTML, with minimal efforts and lines of code.
// https://github.com/hieuvp/xpath-html
Worried Walrus

Ähnliche Antworten wie “Holen Sie sich DOM -Knoten mit XPath”

Fragen ähnlich wie “Holen Sie sich DOM -Knoten mit XPath”

Weitere verwandte Antworten zu “Holen Sie sich DOM -Knoten mit XPath” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen