From:             
Operating system: All
PHP version:      Irrelevant
Package:          *XML functions
Bug Type:         Feature/Change Request
Bug description:XPath processing-instruction() function is not supported.

Description:
------------
SimpleXML misses a XPath function which is processing-instruction(). This
last one enables to reach/select PIs along the XML document.

Test script:
---------------
<?php



$xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n\n" .

       '<foo>' . "\n" .

       '  <bar>Gordon</bar>' . "\n" .

       '  <bar><![CDATA[Gordon]]></bar>' . "\n" .

       '  <bar><?baz href="ftw" ?></bar>' . "\n" .

       '</foo>';



$sxe = simplexml_load_string($xml);



var_dump(

    $sxe->xpath('//bar')

);



var_dump(

    $sxe->xpath('//processing-instruction(\'baz\')')

);

Expected result:
----------------
//bar



array(3) {

  [0]=>

  object(SimpleXMLElement)#2 (1) {

    [0]=>

    string(6) "Gordon"

  }

  [1]=>

  object(SimpleXMLElement)#3 (0) {

  }

  [2]=>

  object(SimpleXMLElement)#4 (1) {

    ["baz"]=>

    object(SimpleXMLElement)#5 (0) {

    }

  }

}





//processing-instruction('baz')

array(1) {

  [2]=>

  object(SimpleXMLElement)#6 (1) {

    …

  }

}

Actual result:
--------------
//bar



array(3) {

  [0]=>

  object(SimpleXMLElement)#2 (1) {

    [0]=>

    string(6) "Gordon"

  }

  [1]=>

  object(SimpleXMLElement)#3 (0) {

  }

  [2]=>

  object(SimpleXMLElement)#4 (1) {

    ["baz"]=>

    object(SimpleXMLElement)#5 (0) {

    }

  }

}





//processing-instruction('baz')

array(0) {

}

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52751&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52751&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52751&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52751&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52751&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52751&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52751&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52751&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52751&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52751&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52751&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52751&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52751&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52751&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52751&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52751&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52751&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52751&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52751&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52751&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52751&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52751&r=mysqlcfg

Reply via email to