You are here: DOM: browse childnodes but not recursively « PHP « IT news, forums, messages
DOM: browse childnodes but not recursively

Posted by Victor Spεng Arthursson on 05/27/05 19:24

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

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация