[xml] xpath query search only first attributes!?



hi

I have a little problem with xpath, using libxml2 within php and
python... here my code

##### test xml #####
<?xml version="1.0"?>
<root>
        <elem1 id="123" name="_boo_">contents 1</elem1>
        <elem2 name="_str_">contents 2</elem2>
</root>
##########

and python

##### xpath.py #####
import libxml2
doc = libxml2.parseFile('test.xml')
for url in doc.xpathEval('//*[contains (@*, "str")]'):
        print url.name
##########

running it

##########
adel adel-workstation:/media/hda5/adel/px$ python xpath.py
elem2
##########

I expected to see "elem1" and "elem2", at first I thought it's php
bug, so I reported it at php bug tracker [1], but a respond there said
it's not php bug, to make sure I re-wrote code in python but yet got
the same result, am stuck here, what wrong with my code?

I hope this right place to ask, thanks in advance

- adel

1) http://bugs.php.net/bug.php?id=41974



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]