php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28188 get_elements_by_tagname("text") return to many elements.
Submitted: 2004-04-27 20:20 UTC Modified: 2004-04-27 21:16 UTC
From: hans at deragon dot biz Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.3.4 OS: Red Hat Linux 9
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.
Password:
Status:
Package:
Bug Type:
Summary:
From: hans at deragon dot biz
New email:
PHP Version: OS:

 

 [2004-04-27 20:20 UTC] hans at deragon dot biz
Description:
------------
When executing $node->get_elements_by_tagname("text"); it is not only the tag named "text" that is returned, but all tags named "#text".  This is wrong.  I am searching for all "text" nodes that are to be found in the input xml file, not those who are named #text and are domtext elements.  Why do domtext element have a name and why are they returned?  

The documentation for states "Every element of the array is an DomElement.".  Not true as DomText are returned too.

Here is the input file "get_elements_by_tagname.xml" used for the test:

<section>
  <text>
    <lang code="default">Hardware clock set to UTC</lang>
    <lang code="fr">Horloge BIOS est UTC</lang>
  </text>
  <widget type="checkbox">
    <default>off</default>
  </widget>
</section>


Reproduce code:
---------------
<?php
                                                                                
    $filename="get_elements_by_tagname.xml";
    if(!$dom = domxml_open_file($filename))
    {
      print "Could not open $filename";
      return;
    }
                                                                                
    $root=$dom->document_element();
    $textnodes=$root->get_elements_by_tagname("text");
    print "<pre>\n";
    print_r($textnodes);
    print "</pre>\n";
?>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-27 21:16 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC