how to get xml item length?

  • adreny
  • Born
  • Born
  • adreny
  • Posts: 3

Post 3+ Months Ago

hi, anyone here please help help me, i write the following code
code:
Code: [ Select ]
var xmlNode = xmlData.firstChild.firstChild;
var total = xmlNode.childNodes.length;
trace(total);
  1. var xmlNode = xmlData.firstChild.firstChild;
  2. var total = xmlNode.childNodes.length;
  3. trace(total);


but the output i get is "5", suppose actual item only have "3".

<rss>
<channel>
<title>Game Shows</title>
<pubdate>19-02-2009</pubdate>
<item>
<thumb>abc1.jpg</thumb>
</item>
<item>
<thumb>abc2.jpg</thumb>
</item>
<item>
<thumb>abc3.jpg</thumb>
</item>
</channel>
</rss>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

5 is correct...

<title />, <pubdate />, <item />, <item />, <item /> are all children of <channel>
  • adreny
  • Born
  • Born
  • adreny
  • Posts: 3

Post 3+ Months Ago

actually i want to loop the <item/]> length, but <title />, <pubdate />. any ideas? got any solution can specified the children name that i want to count?
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

well if you can rewrite the xml to use attributes that would work a bit better.
Code: [ Select ]
<rss>
<channel title="Game Shows" pubdate="19-02-2009">
    <item>
     <thumb>abc1.jpg</thumb>
    </item>
    <item>
     <thumb>abc2.jpg</thumb>
    </item>
    <item>
     <thumb>abc3.jpg</thumb>
    </item>
</channel>
</rss>
  1. <rss>
  2. <channel title="Game Shows" pubdate="19-02-2009">
  3.     <item>
  4.      <thumb>abc1.jpg</thumb>
  5.     </item>
  6.     <item>
  7.      <thumb>abc2.jpg</thumb>
  8.     </item>
  9.     <item>
  10.      <thumb>abc3.jpg</thumb>
  11.     </item>
  12. </channel>
  13. </rss>


then the children are only the items...

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 7 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.