ID:               27524
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ken at world dot std dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: Mac OS X 10.3.2 Build 7D24
 PHP Version:      4.3.4
 New Comment:

next_sibling() takes the next sibling node of the <y> 

element, which is a text node... It has nothing to do 

with get_elements_by_tagname.



get_elements_by_tagname returns an array, you have to 

loop through this, if you only want all the <y> elements


Previous Comments:
------------------------------------------------------------------------

[2004-03-08 01:07:27] ken at world dot std dot com

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>

------------------------------------------------------------------------

[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

Reply via email to