blob: 6e08ffc01f28a6f27823d965b5c083644b0b9bea (
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
|
--TEST--
Bug #43364 (recursive xincludes don't remove internal xml nodes properly)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
function loopElements($nodes)
{
$count = 0;
foreach($nodes as $node) {
if($node instanceof DOMElement) {
$count++;
if($node->childNodes->length > 0) {
$count += loopElements($node->childNodes);
}
}
}
return $count;
}
$xml = <<<DOC
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<a>
<a_child1>ac1</a_child1>
<a_child2>ac2</a_child2>
</a>
<b><xi:include xpointer="xpointer(/root/a)" /></b>
<c><xi:include xpointer="xpointer(/root/b)" /></c>
</root>
DOC;
$doc = new DomDocument();
$doc->loadXml($xml);
$doc->xinclude();
$count = loopElements(array($doc->documentElement));
var_dump($count);
?>
--EXPECT--
int(13)
|