Recursive math, XML nodes, Parsing

ok… I’ll probebly end up solving this in the next couple days… but heck… if someone knows the anwser and saves me time doing this mental exercise, I’ll take the help.

my current parsing technique cycles through my xml doc and turns the doc into a string for output to a dynamic text field. The problem is… it displays all the parent nodes down in order, then it displays all the children nodes of the first parent… then second, and so on.

When I format it and output it I end up with

08-08-02
08-01-02
07-20-02

this week at centerspin…etc

this week at centerspin…etc

this week at centerspin…etc

when I want it to look like this.

08-08-02
this week at centerspin…etc
08-01-02
this week at centerspin…etc
07-20-02
this week at centerspin…etc

Does anyone have a different algorythm that could parse xml data differently than the standard? basicaly… if the node is a type 1 node, start searching it’s children immediately instead of searching the rest of that tier’s nodes?


my solution is that I’m going to work out a clip that contains two text fields and then duplicate it for each type 1 node, filling in the details… I’m sure that this is optimal… but I really don’t feel like having to go through all that when really… I just want to display the xml as one solid string.

any help is appreciated.

Boy no one will even LOOK at a question I post??

:slight_smile:

I loked at your problem…

and …

I dont have the clue… jet…

I gues you solve your problem by naw… o bypased it…

… its hard to be “good” I gues … its hard to get help…

GL.

Hi,

I don’t have a solution but u could have a look at:

http://www.layer51.com/proto/

This guy’s got really cool open source prototypes and don’t know but it’s got an XML section

Cya

SHO

hehe things are too hard…

Hey david,

I would be MORE than glad to help you out, but I still don’t fully understand the XML parsing. I created an XML drop down navigation in Flash, but I still have a problem getting the menu items to drop down. They are just statically down right now. I haven’t worked on it in a while though. Maybe I should get back to that.

If I find anything that could help you out, I will let you know:)

Hey eki…that link you sent…it is pretty cool. I noticed that there is a sbeener there that posted prototypes. I am pretty sure that would be kirupaforum’s very own AS master sbeener (aka supra).

hey upu,

i don’t have much experience with xml … but maybe this is something like what you’re looking for?


function parseXmlRecursive(child){
	var i,nodes = child.childNodes;
	for(i in nodes){
		if(nodes*.hasChildNodes()){
			parseXmlRecursive(nodes*);
		}else{
			trace(nodes*.nodeValue);
		}
	}
}

pass it the first node of the xml object you want to parse.

and (of course) instead of tracing the nodeValue, you’ll want to append it to a string which is returned at the end of the function.

Well if you did it sbeener, it has to be right:) Or at least close to right.

ha! i wish it were true…

I believe it is:) Don’t underestimate yourself sbeener. I think you and Ilyas know the most on this board about AS. Not to put down anyone else, but I see most the tutorials are by you two and I see how well you help out everyone on the board with AS.

Then I looked at those components at that link by you (assuming sbeener is you there also), and that stuff is crazy.

second that!

Sorry guys… I didn’t even see that anyone had replied on this thread.

I appreciate the imput… and you are correct supra… at least in principal. Truthfuly, I’m not a little better on the back swing with the whole recursive thing… I still have problems sometimes getting the information I need out of an xml… but it’s coming along.

upu - it’s hard to be specific without seeing your xml format.

lib, ryall - thanks for raising my spirits! although i can say with some authority that much of what i do is just as f**ked (or more so) as the next guys.

it’s just that by virtue of being a mod, i can edit my posts without anyone knowing. ; )

that is me on layer51, although as i lamented in a seperate thread, those prototypes are of questionable value. writing them was an interesting exercise just the same.

HAHA, boy do I love that feature. I have to edit my posts all the time. I am glad people don’t see how often:)

And not to rub it in or anything but, I TOLD YOU SO:P

david said you were <I>right</I> in principle.

recursives are driving me mad… mad I tell you. They are fascinating and elusive…:x

As for supra… he’s the master… I don’t care what he claims about himself.