Re: [xml] xpath query search only first attributes!?
- From: Bjoern Hoehrmann <derhoermi gmx net>
- To: adel <netdur gmail com>
- Cc: xml gnome org
- Subject: Re: [xml] xpath query search only first attributes!?
- Date: Fri, 13 Jul 2007 00:27:35 +0200
* adel wrote:
##### test xml #####
<?xml version="1.0"?>
<root>
<elem1 id="123" name="_boo_">contents 1</elem1>
<elem2 name="_str_">contents 2</elem2>
</root>
##########
I assume you meant to write _str_ instead of _boo_ here.
for url in doc.xpathEval('//*[contains (@*, "str")]'):
1) http://bugs.php.net/bug.php?id=41974
As the http://www.w3.org/TR/xpath XPath specification explains, this is
the same as //*[contains(string(@*), "str")]; @* evaluates to a node-set
and http://www.w3.org/TR/xpath#function-string
A node-set is converted to a string by returning the string-value
of the node in the node-set that is first in document order. If the
node-set is empty, an empty string is returned.
Further, "The relative order of attribute nodes is implementation-de-
pendent". Use //*[ *[ contains(., 'str') ]] (all elements with one or
more attributes whose value contains 'str').
--
Björn Höhrmann · mailto:bjoern hoehrmann de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]