Version 1 (modified by amachang, 6 years ago)

--

JavaScript-XPath

JavaScript-XPath is a FASTEST js-implementated DOM 3 XPath (XPath 1.0). 1000% Faster than Google Ajaxslt's xpath.js!!

Release/Download

How to use

  • Import JavaScript-Xpath JavaScript File (If browser has native DOM 3 XPath support, this js file do nothing).
  • Enjoy with DOM 3 XPath!

Simple Example

<html>
 <head><title>Hello, DOM 3 XPath!</title>

  <!-- import JavaScript-XPath -->
  <script type="text/javascript" src="javascript-xpath.js"></script>

  <!-- use XPath -->
  <script type="text/javascript">
// <![CDATA[

// -- First case --
// Evaluate a XPath expression string
var result = document.evaluate('//h1', document, null, 7, null);
// Display the result
var h1 = result.snapshotItem(0);
alert(h1.innerHTML); // Hello, DOM 3 XPath!

// -- Second case --
// Create a XPath expression object
var expr = document.createExpression('//h2', null);
// Evaluate a XPath expression object
result = expr.evaluate(document, 7, null);
// Display the result
h1 = result.snapshotItem(0);
alert(h1.innerHTML); // Hello, DOM 3 XPath!
// ]]>
  </script>

 </head><body onload="main()"><h1>Hello, DOM 3 XPath!</h1></body>
</html>

Demo

  • Comming soon.

Speed Test

  • Comming soon.

Binding

  • Comming soon.