note 116622 added to simplexmlelement.xpath

From: Date: Fri, 30 Jan 2015 05:30:38 +0000
Subject: note 116622 added to simplexmlelement.xpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-201562@lists.php.net to get a copy of this message
As mentioned already xpath will fail is the default namespace 'xmlns' is used like in: <?php $xmlstring = $string = <<<XML <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <fileVersion appName="xl" /> </workbook> XML; ?> xpath cannot search through the xml without explicitly specifying a namespace. There are 2 options : 1. rename the 'xmlns' into something else to trick xpath into believing that no default namespace is defined. 2. register a string as the default namespace and use that string in all your queries. Unfortunatly, an empty space will not work. No other option currently exist until XPath2.0 becomes the default library. ---- Server IP: 72.52.91.14 Probable Submitter: 124.39.122.119 ---- Manual Page -- http://php.net/manual/en/simplexmlelement.xpath.php Edit -- https://master.php.net/note/edit/116622 Del: integrated -- https://master.php.net/note/delete/116622/integrated Del: useless -- https://master.php.net/note/delete/116622/useless Del: bad code -- https://master.php.net/note/delete/116622/bad+code Del: spam -- https://master.php.net/note/delete/116622/spam Del: non-english -- https://master.php.net/note/delete/116622/non-english Del: in docs -- https://master.php.net/note/delete/116622/in+docs Del: other reasons-- https://master.php.net/note/delete/116622 Reject -- https://master.php.net/note/reject/116622 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201562) next »