blob: 8734ba4a46312c9b05e50ce18be61d550124e1db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
--TEST--
SimpleXML: XPath
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--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
Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in %s on line %d
bool(false)
|