Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <script>
- function ns_resolver(prefix) {
- var ns = {
- 'uuk': 'http://uukgoblin.com/namespace'
- };
- return ns[prefix] || null;
- }
- function search() {
- var res = document.evaluate('//p[@uuk:attr="val"]', document, ns_resolver, XPathResult.ANY_TYPE, null);
- var first = res.iterateNext();
- if(first === null) {
- alert("not found");
- }
- }
- </script>
- </head>
- <body>
- <div xmlns:uuk="http://uukgoblin.com/namespace">
- <p uuk:attr="val">hello</p>
- </div>
- <input type="button" value="clickme" onclick="search()" />
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement