| Version 11 (modified by amachang, 6 years ago) |
|---|
JavaScript-XPath
JavaScript-XPath is the FASTEST DOM 3 XPath (XPath 1.0) implementation in JavaScript.
This code runs 10 times faster than Google Ajaxslt's xpath.js!!
Release/Download
- Latest Version
- If you have a svn client installed, check out the trunk with:
svn co http://svn.coderepos.org/share/lang/javascript/javascript-xpath/trunk/ jsxpath
How to use
- Import JavaScript-Xpath JavaScript File (this js file does nothing for browsers which support DOM 3 XPath natively).
- 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[
function main() {
// -- 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('//h1', 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>
Supported Browser
- Internet Explorer 6
- Internet Explorer 7
- Safari 2+
- Any Other DOM Core Supported Browser
Native DOM 3 XPath Supported Browser
- Firefox 1+
- Safari 3+
- Opera 9+
Demo
- Coming soon.
Functional Test
Speed Test
- Coming soon.
Binding
- Coming soon.
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)