|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26815 foreach (DOM) childnodes causes error when using Xinclude
Submitted: 2004-01-06 11:26 UTC Modified: 2004-01-07 10:31 UTC
From: bart at mediawave dot nl Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.0.0b3 (beta3) OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bart at mediawave dot nl
New email:
PHP Version: OS:


 [2004-01-06 11:26 UTC] bart at mediawave dot nl
I used the Xinclude PHP5 example from Bitflux. Then when I tried to iterate through the resulting DOM object I got an access violation.

Reproduce code:
class VariableStream {
    var $position;
    var $varname;
    function stream_open($path, $mode, $options, &$opened_path) {
        $url = parse_url($path);
        $this->varname = $url["host"];
        $this->position = 0;
        return true;
    function stream_read($count) {
        $ret = substr($GLOBALS[$this->varname], $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    function stream_eof() {
        return $this->position >= strlen($GLOBALS[$this->varname]);
    function url_stat() {
        return array();

$xmlstring = '<?xml version="1.0"?>
<foo xmlns:xi="">
    <xi:include href="var://bar#xpointer(/foo/bar)"/>

stream_wrapper_register("var", "VariableStream");

$bar = '<foo><bar>hello world</bar></foo>';
$dom = new domdocument;

print nl2br(htmlspecialchars($dom->saveXML()));

foreach ($dom->documentElement->childNodes AS $node) {
	echo '<br>';
	echo $node->nodeName;
	echo ' - ';
	echo $node->nodeValue;

Expected result:
<?xml version="1.0"?>
<foo xmlns:xi="">
<xi:include href="var://bar#xpointer(/foo/bar)"/>

#text - 
bar - hello world
#text - 

Actual result:
<?xml version="1.0"?>
<foo xmlns:xi="">
<bar xml:base="var://bar">hello world</bar>

#text - 
Warning: main() [function.main]: Unsupported node type: 19 in E:\projects\projects\^General\Wrapper\wrap_v5\domtest.php on line 44

- PHP has encountered an Access Violation at 018BC3B2


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-06 11:29 UTC] bart at mediawave dot nl
Oops: Expected result should be:

<?xml version="1.0"?>
<foo xmlns:xi="">
<bar xml:base="var://bar">hello world</bar>

#text - 
bar - hello world
#text -
 [2004-01-07 10:31 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Mar 20 18:03:40 2023 UTC