#27524 [Opn]: get_elements_by_tagname

From: Date: Mon, 08 Mar 2004 06:07:29 +0000
Subject: #27524 [Opn]: get_elements_by_tagname
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-56073@lists.php.net to get a copy of this message
ID: 27524 User updated by: ken at world dot std dot com Reported By: ken at world dot std dot com Status: Open Bug Type: DOM XML related Operating System: Mac OS X 10.3.2 Build 7D24 PHP Version: 4.3.4 New Comment: Hi, Sorry, I forgot to include the XML file which I was using to generate the output. Here it is: <?xml version="1.0" encoding="iso-8859-1"?> <x> <y> Item 1 </y> <y> Item 2 </y> <y> Item 3 </y> <y> Item 4 </y> </x> Previous Comments: ------------------------------------------------------------------------ [2004-03-08 01:03:45] ken at world dot std dot com Description: ------------ Hi, I'm new to using the PHP DOM interface, so I apologize if this "bug" is my misunderstanding of the specs, but I haven't seen any mention of this anywhere yet. I'm using the get_elements_by_tagname Reproduce code: --------------- $dom = domxml_open_file("XMLBugTest.xml"); $temp = $dom->get_elements_by_tagname("x"); $y_nodes = $temp[0]->get_elements_by_tagname("y"); // Access the first node $current_node = $y_nodes[0]; // Initialize the node counter $nodecount = 0; // Process each node in the collection while($current_node) { echo "<br>" . $current_node->node_type() . " -- " . $current_node->node_name() . " -- " . $current_node->get_content(); // Count this node $nodecount++; // Get the next node in the collection $current_node = $current_node->next_sibling(); } // Report the total node count echo "<br>Number of processed nodes: " . $nodecount; Expected result: ---------------- 1 -- y -- Item 1 1 -- y -- Item 2 1 -- y -- Item 3 1 -- y -- Item 4 Number of processed nodes: 4 Actual result: -------------- 1 -- y -- Item 1 3 -- #text -- 1 -- y -- Item 2 3 -- #text -- 1 -- y -- Item 3 3 -- #text -- 1 -- y -- Item 4 3 -- #text -- Number of processed nodes: 8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27524&edit=1

« previous php.bugs (#56073) next »