Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- SimpleXML: XPath --EXTENSIONS-- simplexml --FILE-- <?php $xml =<<<EOF <?xml vers..

Decoded Output download

--TEST--
SimpleXML: XPath
--EXTENSIONS--
simplexml
--FILE--
<?php

$xml =<<<EOF
<?xml version='1.0'?>
<!DOCTYPE sxe SYSTEM "notfound.dtd">
<sxe id="elem1">
 <elem1 attr1='first'>
  <!-- comment -->
  <elem2>
   <elem3>
    <elem4>
     <?test processing instruction ?>
    </elem4>
   </elem3>
  </elem2>
 </elem1>
</sxe>
EOF;

$sxe = simplexml_load_string($xml);

var_dump($sxe->xpath("elem1/elem2/elem3/elem4"));
//valid expression
var_dump($sxe->xpath("***"));
//invalid expression
var_dump($sxe->xpath("**"));
?>
--EXPECTF--
array(1) {
  [0]=>
  object(SimpleXMLElement)#%d (1) {
    ["test"]=>
    object(SimpleXMLElement)#%d (0) {
    }
  }
}
array(0) {
}

Warning: SimpleXMLElement::xpath(): Invalid expression in %s on line %d%A
bool(false)

Did this file decode correctly?

Original Code

--TEST--
SimpleXML: XPath
--EXTENSIONS--
simplexml
--FILE--
<?php

$xml =<<<EOF
<?xml version='1.0'?>
<!DOCTYPE sxe SYSTEM "notfound.dtd">
<sxe id="elem1">
 <elem1 attr1='first'>
  <!-- comment -->
  <elem2>
   <elem3>
    <elem4>
     <?test processing instruction ?>
    </elem4>
   </elem3>
  </elem2>
 </elem1>
</sxe>
EOF;

$sxe = simplexml_load_string($xml);

var_dump($sxe->xpath("elem1/elem2/elem3/elem4"));
//valid expression
var_dump($sxe->xpath("***"));
//invalid expression
var_dump($sxe->xpath("**"));
?>
--EXPECTF--
array(1) {
  [0]=>
  object(SimpleXMLElement)#%d (1) {
    ["test"]=>
    object(SimpleXMLElement)#%d (0) {
    }
  }
}
array(0) {
}

Warning: SimpleXMLElement::xpath(): Invalid expression in %s on line %d%A
bool(false)

Function Calls

simplexml_load_string 1

Variables

$xml <?xml version='1.0'?> <!DOCTYPE sxe SYSTEM "notfound.dtd"> <..

Stats

MD5 7f44060798ed241225be36c9f49fd5da
Eval Count 0
Decode Time 83 ms