File tree Expand file tree Collapse file tree 3 files changed +63
-1
lines changed Expand file tree Collapse file tree 3 files changed +63
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ PHP NEWS
35
35
. Fixed persistent procedural ODBC connections not getting closed.
36
36
(NattyNarwhal)
37
37
38
+ - SimpleXML:
39
+ . Fixed bug #52751 (XPath processing-instruction() function is not
40
+ supported). (nielsdos)
41
+
38
42
- SPL:
39
43
. Fixed bug GH-11972 (RecursiveCallbackFilterIterator regression in 8.1.18).
40
44
(nielsdos)
Original file line number Diff line number Diff line change @@ -1322,7 +1322,7 @@ PHP_METHOD(SimpleXMLElement, xpath)
1322
1322
1323
1323
for (i = 0 ; i < result -> nodeNr ; ++ i ) {
1324
1324
nodeptr = result -> nodeTab [i ];
1325
- if (nodeptr -> type == XML_TEXT_NODE || nodeptr -> type == XML_ELEMENT_NODE || nodeptr -> type == XML_ATTRIBUTE_NODE ) {
1325
+ if (nodeptr -> type == XML_TEXT_NODE || nodeptr -> type == XML_ELEMENT_NODE || nodeptr -> type == XML_ATTRIBUTE_NODE || nodeptr -> type == XML_PI_NODE ) {
1326
1326
/**
1327
1327
* Detect the case where the last selector is text(), simplexml
1328
1328
* always accesses the text() child by default, therefore we assign
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #52751 (XPath processing-instruction() function is not supported)
3
+ --EXTENSIONS--
4
+ simplexml
5
+ --FILE--
6
+ <?php
7
+
8
+ $ xml = <<<XML
9
+ <?xml version="1.0" encoding="utf-8"?>
10
+ <foo>
11
+ <bar>text node</bar>
12
+ <bar><?baz href="ftw" ?></bar>
13
+ <bar><?foo bar ?></bar>
14
+ </foo>
15
+ XML ;
16
+
17
+ $ sxe = simplexml_load_string ($ xml );
18
+
19
+ var_dump (
20
+ $ sxe ->xpath ('//bar ' )
21
+ );
22
+
23
+ var_dump (
24
+ $ sxe ->xpath ('//processing-instruction( \'baz \') ' )
25
+ );
26
+
27
+ foreach ($ sxe ->xpath ('//processing-instruction() ' ) as $ pi ) {
28
+ var_dump ($ pi ->getName ());
29
+ }
30
+
31
+ ?>
32
+ --EXPECT--
33
+ array(3) {
34
+ [0]=>
35
+ object(SimpleXMLElement)#2 (1) {
36
+ [0]=>
37
+ string(9) "text node"
38
+ }
39
+ [1]=>
40
+ object(SimpleXMLElement)#3 (1) {
41
+ ["baz"]=>
42
+ object(SimpleXMLElement)#5 (0) {
43
+ }
44
+ }
45
+ [2]=>
46
+ object(SimpleXMLElement)#4 (1) {
47
+ ["foo"]=>
48
+ object(SimpleXMLElement)#5 (0) {
49
+ }
50
+ }
51
+ }
52
+ array(1) {
53
+ [0]=>
54
+ object(SimpleXMLElement)#4 (0) {
55
+ }
56
+ }
57
+ string(3) "baz"
58
+ string(3) "foo"
You can’t perform that action at this time.
0 commit comments