note 69638 added to function.simplexml-element-xpath
| From: | brettz9throughyah at osu1 dot php dot net | Date: | Wed, 13 Sep 2006 14:31:23 +0000 |
| Subject: | note 69638 added to function.simplexml-element-xpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117109@lists.php.net to get a copy of this message | ||
I was looking to find all of a given element type with attributes which were not of a particular
value (including null items).
I tried this...
<?php
$xml->xpath("//pg[@show!='none']");
?>
...But that only worked if there was in fact some attribute.
I thought this should work (shouldn't it?), but it didn't:
<?php
$xml->xpath("//pg[@show!='none' or !@show]");
?>
The solution is to use the not() function:
<?php
$xml->xpath("//pg[not(@show='none')]");
?>
----
Server IP: 66.163.161.117
Probable Submitter: 218.17.96.1
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-xpath.php
Edit -- https://master.php.net/note/edit/69638
Del: integrated -- https://master.php.net/note/delete/69638/integrated
Del: useless -- https://master.php.net/note/delete/69638/useless
Del: bad code -- https://master.php.net/note/delete/69638/bad+code
Del: spam -- https://master.php.net/note/delete/69638/spam
Del: non-english -- https://master.php.net/note/delete/69638/non-english
Del: in docs -- https://master.php.net/note/delete/69638/in+docs
Del: other reasons-- https://master.php.net/note/delete/69638
Reject -- https://master.php.net/note/reject/69638
Search -- https://master.php.net/manage/user-notes.php