|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26205 DomDocument->get_elements_by_tagname does not find children or attributes
Submitted: 2003-11-11 12:22 UTC Modified: 2003-11-25 03:25 UTC
From: jenny dot watt at continuetolearn dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.3.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
38 - 14 = ?
Subscribe to this entry?

 [2003-11-11 12:22 UTC] jenny dot watt at continuetolearn dot com
I am opening an XML file and retrieving data using the get DomDocument->get_elements_by_tagname() function.

This works on my Windows XP running 4.3.4 and it worked on the Unix system running 4.2.4 but when it was upgraded to 4.3.4 I can get simple tag names but not the child tags or attributes of a tag.

From what I understand from the administrator, this was only an upgrade to PHP.

Reproduce code:
//---- statements that call function
$courseDetails = domxml_open_file("quiz.xml");
$form->format = get_content($courseDetails,"questions/@TYPE");
$form->openyear = get_content($courseDetails,"timeopen/year");

//---- function called by statements above ----
function get_content($rootObject,$objectName){
  if(!$objectList = $rootObject->get_elements_by_tagname($objectName)){
     echo "error1";
     return "";
  $firstChild = $objectList[0]->first_child();
  if($firstChild->node_name() == "#text"){
    $objectValue = $objectList[0]->get_content();
    return $objectValue;
  return "";
//---- file this code is called on "quiz.xml" -----
<?xml version="1.0" encoding="iso-8859-1"?>
  <questions TYPE="blackboard">

Expected result:
should assign $form->format the value of "blackboard" and $form->openyear the value of "2003"

Actual result:
It will print "error1" for both and assign them the value of "".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-11 13:13 UTC]
you are using xpath-expressions and not simple element-names. This may had worked with older php versions, but the internal code was changed later. 

If you want to use something like "timeopen/year" then use the appropriate xpath methods (see manual..)

 [2003-11-11 13:14 UTC]

auto-form-completion went crazy and changed the summary...

changing back
 [2003-11-25 01:54 UTC] megazone at cyphermint dot com
Someone should remove the comment in the online documentation that shows XPath being used if it is not valid:
 [2003-11-25 03:25 UTC]
It is deleted now
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Sep 30 21:05:59 2022 UTC