DOM: browse childnodes but not recursively

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ciao!

I really hope someone can help me on this, since I have been putting in to much time in it now, and I have to show off some results ;)

The problem is that I can't browse nodelists in only one dimension, that is, whitout getting the sub-nodes of the nodes.

My XML reads:

<element id="5">
    <element id="51">Still got the blues</element>
    <element id="52">Gary Moore</element>
    <element id="53">
        <element id="9">
            <element id="531">Maggie May</element>
            <element id="532">Rod Stewart</element>
            <element id="533">UK</element>
            <element id="534">Pickwick</element>
            <element id="535">8.50</element>
            <element id="536">1990</element>
        </element>
       </element>
    <element id="54">Virgin records</element>
    <element id="55">10.20</element>
    <element id="56">1990</element>
</element>

I get this as a DOMNodeList in the variable $elements. I will write some examples, to describe my problem.

echo $elements->length;
// outputs 1

var_dump($elements);
// outputs object(DOMNodeList)#5 (0) { }

var_dump($elements->item(0)); // contents of element with id="5"
// outputs object(DOMElement)#4 (0) { }

Here I come to the problem. What I want is to get a list of the 6 elements inside element id="5", but not with child-childs.

echo $elements->item(0)->childNodes->length;
// Outputs 13!!!!!

So, to put it in short words; how do I do to browse the content of the element id="5" withuot doing it recursively? I want to receive a list when I call childNodes (or equivalent) that gives me the elements with id 51-56, and a length of 6.

Really really thankful for any input on the matter!!!!

Sincerely

Victor

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux