Giter VIP home page Giter VIP logo

simple-xpath-position's Introduction

Simple XPath Position

Build Status NPM Package Coverage

Create and evaluate simple XPath position expressions.

Installation

Using npm:

npm install simple-xpath-position

Usage

The module provides functions for describing and locating a DOM Node using an XPath expression.

API

fromNode(node, [root])

Convert a Node to an XPath expression.

If the optional parameter root is supplied, the computed XPath expression will be relative to it. Otherwise, the root of the document to which node belongs is used as the root.

Returns a string.

toNode(path, root, [resolver])

Locate a single Node that matches the given XPath expression. The XPath expressions are evaluated relative to the Node argument root.

If the optional parameter resolver is supplied, it will be used to resolve any namespaces within the XPath expression.

Returns a Node or null.

Compatibility

This library should work with any browser.

The presence of a working XPath evaluator is not strictly required. Without it, the library will only support XPath expressions that use a child axis and node names with number literal positions. All XPath expressions generated by this library fit this description. For instance, the library can generate and consume an expression such as /html/body/article/p[3].

For better XPath support, consider bundling an implementation such as the Wicked Good XPath library.

Internet Explorer version 8

  • There is no support for namespaces in X(HT)ML documents.

Community

Originally, this code was part of the Annotator project.

Any discussion should happen on the annotator-dev mailing list.

Development

To contribute, fork this repository and send a pull request with your changes, including any necessary test and documentation updates.

Testing

You can run the command-line test suite by executing npm test.

To run the test suite, install the karma test runner with the command npm install -g karma-cli and then run karma start. Karma will print instructions for debugging the tests in a browser.

simple-xpath-position's People

Contributors

aron avatar csillag avatar nickstenning avatar rufuspollock avatar tilgovi avatar wjt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.