Socket
Socket
Sign inDemoInstall

xpath

Package Overview
Dependencies
0
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    xpath

DOM 3 Xpath implemention and helper for node.js.


Version published
Weekly downloads
2.3M
increased by6%
Maintainers
2
Install size
158 kB
Created
Weekly downloads
 

Package description

What is xpath?

The xpath npm package is a Node.js module that allows users to query XML documents using XPath expressions. It provides a way to navigate and select nodes in an XML document tree, extract information, and manipulate the content.

What are xpath's main functionalities?

Evaluating XPath expressions

This feature allows you to evaluate XPath expressions against an XML document and returns the matching nodes.

const xpath = require('xpath'),
     dom = require('xmldom').DOMParser;
let doc = new dom().parseFromString('<book><title>Harry Potter</title></book>');
let nodes = xpath.select('//title', doc);
console.log(nodes[0].textContent); // Harry Potter

Registering custom namespaces

This feature enables the use of custom namespaces when evaluating XPath expressions, which is necessary when querying XML documents that include namespaces.

const select = xpath.useNamespaces({
  'x': 'http://www.w3.org/1999/xhtml'
});
let nodes = select('//x:div', doc);

Using XPath functions

This feature allows the use of XPath functions within the expression to perform operations like counting nodes, string manipulation, etc.

let result = xpath.select('count(//title)', doc);
console.log(result); // 1

Other packages similar to xpath

Keywords

FAQs

Last updated on 25 Jan 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc