Give XPath a Try -- version 0.13

This page has only been tested with Firefox. You can try to modify this page to support both Firefox and Microsoft IE.

This page was developed mainly based on the materials from Introduction to using XPath in JavaScript - MDC and Using the Mozilla Javascript Interface to XPath. As of writing (03/2007), it seems to me that XPath 2.0 is NOT supported.

這個版本特別針對因為 whitespaces 所造成的 TEXT_NODE 而設計。 目前設計的方式如下: TEXT_NODE 的 nodeName 為 #text,所以 我們將 nodeValue 的前以及後的空格移除(也就是 trim)的動作, trim 之後還有值的字串,我們把它列印出來。這個設計的缺點在於 如果這些空格是有意義的,我們也會將它們刪除,例如 < this > 會被處理成 <this>。

目前,Mozilla/Firefox 對於命名空間(Namespace)的解決方式並不完整。 因此,如果你自行定義了一些 namespace,這個測試就沒辦法順利的 處理。這個網頁的解決方式,只是把用到的 namespace 如 rcp 內建在網頁, 想測試的,請使用 recipes.xml 當做範例,至於其他的 namespace 就等我有需要才慢僈加上去,或者等到 Mozilla/Firefox 提出一個解決 方法。

Right now, the available local XML files are xpath.xml (an adapted example from W3Schools), recipes.xml (an adapted example from the textbook by Moller and Schwartzbach), Ch6-3-2.xml, and Ch6-4.xml. Or, you can query a remote XML file by providing its complete URL.

Enter URL: or simply books.xml
Enter XPath Expression: