raphaellouis
2022-05-22
Hi all!
Feature name
[Idea] API Web Javascript Xpath
Feature description
- I wish there was an api to parse html in a standardized way. Currently, I have to use third-party libraries for this.
- If one existed a standardized xpath api, I could create an extension on google, to analyze and send information from the site that I need easily and accurately
- There are several documentations made about this, but there is no minimalistic and easy api for this. Reference here: interface-xpathexpression or here DOM_XPath or here xpath spec or here DOM-Level-3-XPath or here 0310
before.js
var xpath = "//div";
var evaluator = new XPathEvaluator();
var expression = evaluator.createExpression(xpath);
var result = expression.evaluate(document, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
document.querySelector("output").textContent = result.snapshotLength;
after.js
var select, dom = require('xmldom').DOMParser
var xml = "<book><title>Harry Potter</title></book>"
var doc = new dom().parseFromString(xml)
var nodes = select(doc, "//title")
console.log(nodes[0].localName + ": " + nodes[0].firstChild.data)
console.log("node: " + nodes[0].toString())
References
- GitHub - yaronn/xpath.js: An xpath module for node, written in pure javascript
- XPathExpression - Web APIs | MDN
- GitHub - antchfx/xpath: XPath package for Golang, supports HTML, XML, JSON document query.
- GitHub - hieuvp/xpath-html: Easily use XPath to locate any element in an HTML DOM page.
- GitHub - goto100/xpath: DOM 3 Xpath implemention and helper for node.js
- GitHub - philou/xpath-specs: An RSpec library to get better messages when matching XPaths
- GitHub - teamcapybara/xpath: Ruby library for generating XPath expressions
- GitHub - kyleburton/clj-xpath: Simplified XPath Library for Clojure
- GitHub - r0oth3x49/Xpath: A python based cross-platform tool that automates the process of detecting and exploiting error-based injection security flaws.
- GitHub - sissaschool/elementpath: XPath 1.0/2.0/3.0 parsers and selectors for ElementTree and lxml
- Using XPath expressions with the Message Filter Primitive for WebSphere Process Server (WPS) and WebSphere Enterprise Service Bus (WESB)