xpath: how to select node based on attribute value only?
John Stewart <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm trying to iterate through all nodes that have some attribute, say "id". I can say:
?- load_my_thing("foo.xml", XML),xpath(XML, //'*'(@id), P).
And I get back all the id attributes. And I can ask for the element content for a known value for a known element name:
?- load_my_thing("foo.xml", XML), xpath(XML, //h2(@id='x-ck12-TGVzc29uIFJldmlldyBRdWVzdGlvbnM.-r07'), P).
...
P = element(h2, [id='x-ck12-TGVzc29uIFJldmlldyBRdWVzdGlvbnM.-r07'], [' Lesson Review Questions\n '])
But I haven't worked out how to find the element with known attribute but not known element name:
?- load_my_thing("foo.xml", XML), xpath(XML, //'*'(@id='x-ck12-TGVzc29uIFJldmlldyBRdWVzdGlvbnM.-r07'), P).
false.
Any help appreciated. Thanks.
jds
-------------- next part --------------
HTML attachment scrubbed and removed