How to get parent node with xpath?
Nikita Sidorov <nikitasidorov-JGs/[email protected]> Wed, 24 Jan 2007 16:07:55 +0000 (UTC)
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Hi!
I'm a bit confused about the way xpath works. Why doesn't it return parent node
on path ".."? Suppose the following code:
(define (xpath-first path xml)
(let ((result ((txpath path) xml)))
(if (pair? result)
(car result)
#f)))
(define parent (sxml:add-parents '(parent
(child "a"))))
Next expression returns 'parent' node as supposed:
(xpath-first "//child/.." parent)
Next two expressions seem to return the same result, but they do not:
(xpath-first ".." (xpath-first "//child" parent))
(xpath-first "parent::*" (xpath-first "//child" parent))
At the same time it is possible to get parent node manually:
((cadr (sxml:aux-node (xpath-first "//child" parent) '*PARENT*)))
So, why doesn't path ".." works? Probably, I should use some other path?
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV