note 94391 added to simplexmlelement.xpath

From: Date: Mon, 02 Nov 2009 07:21:05 +0000
Subject: note 94391 added to simplexmlelement.xpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-162327@lists.php.net to get a copy of this message
Regarding the problem described by paul at pmtlogic dot com about single quotes: His query code... <?php // ... $result = $xml->xpath("//zone[@country='Cote d\'Ivoire']"); // ... ?> ...is incorrect. In double-quoted strings in PHP, to insert a backslash, you need to double it. There is no need to escape single quotes in double-quoted things. His code should have read... <?php // ... $result = $xml->xpath("//zone[@country='Cote d\\'Ivoire']"); // ... ?> ...which may have had a better change of working correctly (we want one backslash to be sent to the xpath interpreter to escape the single quote). His original code would have silently dropped the superfluous backslash character at the PHP level, resulting in an un-escaped single quote within a single-quoted string at the xpath level. ---- Server IP: 69.147.83.197 Probable Submitter: 69.171.164.231 ---- Manual Page -- http://www.php.net/manual/en/simplexmlelement.xpath.php Edit -- https://master.php.net/note/edit/94391 Del: integrated -- https://master.php.net/note/delete/94391/integrated Del: useless -- https://master.php.net/note/delete/94391/useless Del: bad code -- https://master.php.net/note/delete/94391/bad+code Del: spam -- https://master.php.net/note/delete/94391/spam Del: non-english -- https://master.php.net/note/delete/94391/non-english Del: in docs -- https://master.php.net/note/delete/94391/in+docs Del: other reasons-- https://master.php.net/note/delete/94391 Reject -- https://master.php.net/note/reject/94391 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162327) next »