ID: 26205 Updated by: [EMAIL PROTECTED] -Summary: DomDocument->get_elements_by_tagname does not find children or attributes Reported By: jenny dot watt at continuetolearn dot com -Status: Open +Status: Bogus Bug Type: DOM XML related -Operating System: Unix +Operating System: Linux -PHP Version: 4.3.4 +PHP Version: 4.3.3 New Comment:
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..) chregu Previous Comments: ------------------------------------------------------------------------ [2003-11-11 12:22:23] jenny dot watt at continuetolearn dot com 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 this bug report at http://bugs.php.net/?id=26205&edit=1