php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31409 Element is in wrong Namespace
Submitted: 2005-01-04 19:01 UTC Modified: 2005-01-04 22:22 UTC
From: joern_h at gmx dot net Assigned:
Status: Not a bug Package: XML related
PHP Version: 5.0.3 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joern_h at gmx dot net
New email:
PHP Version: OS:

 

 [2005-01-04 19:01 UTC] joern_h at gmx dot net
Description:
------------
When an empty element is has a xmlns attribute the element following it is also reported to be in this namespace. In the following example the 'a' element is wrongly reported as being in the 'http://t/' namespace.

Reproduce code:
---------------
<?php

$xml = <<<HERE
<?xml version="1.0" encoding="utf-8" ?>
<root>
    <test xmlns="http://t/" />
    <a />
</root>
HERE;

$parser =& xml_parser_create_ns('utf-8', ';');
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, true);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);

$index = array();
$vals  = array();
if (!xml_parse_into_struct($parser, $xml, $vals, $index)) {
    echo xml_error_string(xml_get_error_code($parser)) . "\n";
}
print_r($vals);

xml_parser_free($parser);

?>

Expected result:
----------------
Array
(
    [0] => Array
        (
            [tag] => root
            [type] => open
            [level] => 1
        )

    [1] => Array
        (
            [tag] => http://t/;test
            [type] => complete
            [level] => 2
        )

    [2] => Array
        (
            [tag] => a
            [type] => complete
            [level] => 2
        )

    [3] => Array
        (
            [tag] => root
            [type] => close
            [level] => 1
        )

)

Actual result:
--------------
Array
(
    [0] => Array
        (
            [tag] => root
            [type] => open
            [level] => 1
        )

    [1] => Array
        (
            [tag] => http://t/;test
            [type] => complete
            [level] => 2
        )

    [2] => Array
        (
            [tag] => http://t/;a
            [type] => complete
            [level] => 2
        )

    [3] => Array
        (
            [tag] => root
            [type] => close
            [level] => 1
        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-04 22:22 UTC] rrichards@php.net
This is a bug in libxml not PHP. issue being addressed there.
For workaround use full open and closing tags for empty elements defining namespaces:
<test xmlns="http://t/"></test>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 00:01:32 2024 UTC