I am looking for an AJAX JavaScript library that supports namespaced xml.
I read dozens of posts on the web (including on stackoverflow) but didn’t find a good answer. There are many AJAX examples, but they break as soon as namespaces come into play (it is the case for example with jQuery selectors).
I do not know exactly what you are calling an “AJAX JavaScript library” – making HTTP requests is a problem different from accessing nodes in a document tree.
If you understand a library as “a collection of resources used to develop software” (Wikipedia), then, as part of the JSX library, I have written rather compatible¹ wrappers for
XMLHttpRequestand namespace-aware DOM Level 3 XPath:http.jsandxpath.js.http.jssupports synchronous and asynchronous processing in the same way, and can even access the local filesystem (if permission is granted). Because JSX qualifies as a library then, you can usehttp.jsandxpath.jseither separately, with foreign code to complement either one, or together.You would use them together, for example, as follows. Suppose you had an XML document with resource name
test.xmllikeand you wanted to extract the
1.0from itsres:UNDO_COUNTelement, you could write:See also: Parsing XML / RSS from URL using Java Script
¹ A combination of JSX:
object.js,http.js, andxpath.jshas been tested positive in Gecko-, WebCore-, MSHTML-based and Opera browsers. However, JSX is mostly experimental code for now.Testcase, see script console
Constructive feedback is welcome. In addition, JSX is free software. (You cannot do a
checkoutyet, but I am working on it.)