php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33573 strange return value in get_elements_by_tagname()
Submitted: 2005-07-05 11:58 UTC Modified: 2005-07-11 15:03 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: timo dot schmid at gmail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.4 OS: Windows XP
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: timo dot schmid at gmail dot com
New email:
PHP Version: OS:

 

 [2005-07-05 11:58 UTC] timo dot schmid at gmail dot com
Description:
------------
The function seems to return a the DB-Object twice. One of the Objects is valid, the other is missing data.

Reproduce code:
---------------
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>
	<settings>
        <db>
	<user>root</user>
	<pw>topsecret</pw>
	<host>localhost</host>
	<type>mysql</type>
	<db>mydatabase</db>
	<fetchmode>3</fetchmode>
	<autocommit>on</autocommit>
	</db>
	</settings>';
	$dom = new DomDocument($xml);
	$root = $dom->document_element();
	print '<pre>';
	var_dump($root->get_elements_by_tagname('db'));
	print '</pre>';
?>

Expected result:
----------------
array(1) {
  [0]=>
  object(domelement)#3 (4) {
    ["type"]=>
    int(1)
    ["tagname"]=>
    string(2) "db"
    [0]=>
    int(4)
    [1]=>
    int(22694840)
  }
}
or something similar...

Actual result:
--------------
array(2) {
  [0]=>
  object(domelement)#3 (4) {
    ["type"]=>
    int(1)
    ["tagname"]=>
    string(2) "db"
    [0]=>
    int(4)
    [1]=>
    int(22694840)
  }
  [1]=>
  object(domelement)#4 (4) {
    ["type"]=>
    int(1)
    ["tagname"]=>
    string(2) "db"
    [0]=>
    int(5)
    [1]=>
    int(22693552)
  }
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-05 12:50 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-07-11 15:03 UTC] chregu@php.net
you have to "db" elements below the $root element. So this is expected behaviour.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC