Skip to main content
April 24, 2006
Answered

parsing a partial XML list

  • April 24, 2006
  • 5 replies
  • 490 views
Ok, so I have a news section on a site that looks to an XML file to load the news. And there are about 20 news headlines in there, and the scrollbar is getting way too tiny. So, what I would like to do is have it display 10 of the headlines and then stop, but I will have a button to open an archive window so you can see all of the headlines. I know I can make 2 sections of the xml, one for the current 10 and one for the archive, but I would like to have it just pull from the same xml section and have one of them just parse 10 headlines and one parse all of them. Here's my actionscript to call the xml file, I tried changed the var=0 to var=10, but that displays everything under the 10th, and I'd rather have it display everything b/w 1 and 10, thanks in advance.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer blemmo
Hm, is there an info for which variable the type mismatch is found? Maybe it's objNewsPath, it should be a XMLNode object, maybe you try to pass a XML object instead? In a test, I used the first child of a XML object (the root element) for the function, worked fine.
You could rewrite the function to accept XML objects, but then the reading (the for loop) would look a bit different.

5 replies

April 24, 2006
Oh I got it working. Thanks a lot for your help man!! or woman...
Inspiring
April 24, 2006
Hi,

use the attached function. If you specify a 'max' parameter, e.g. 10, it stops after this number of entries. If you don't pass anything for 'max', it goes through the complete xml.

cheers,
blemmo

April 24, 2006
Thanks for the response, you'll have to excuse me for being a bit of a noob. Should I be able to just copy and paste that code into my flash file? I'm getting an output error of "type mismatch" on the ( var strHTMLNewsText:String = parseFile(objNewsPath, 10); ) line. Not sure what I'm doing wrong here. Thanks again.
blemmoCorrect answer
Inspiring
April 24, 2006
Hm, is there an info for which variable the type mismatch is found? Maybe it's objNewsPath, it should be a XMLNode object, maybe you try to pass a XML object instead? In a test, I used the first child of a XML object (the root element) for the function, worked fine.
You could rewrite the function to accept XML objects, but then the reading (the for loop) would look a bit different.