From: jenny dot watt at continuetolearn dot com
Operating system: Unix
PHP version: 4.3.4
PHP Bug Type: DOM XML related
Bug description: DomDocument->get_elements_by_tagname does not find children or
attributes
Description:
------------
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"?>
<quiz>
<timeopen>
<year>2003</year>
</timeopen>
<questions TYPE="blackboard">
<file>res00001.dat</file>
</questions>
</quiz>
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 "".
--
Edit bug report at http://bugs.php.net/?id=26205&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26205&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26205&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26205&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26205&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26205&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=26205&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26205&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26205&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26205&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26205&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26205&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26205&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26205&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26205&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26205&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26205&r=float