Ultrashock Forums > Flash > ActionScript > XML
XML newbie need help...

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
XML newbie need help...
Old 2001-08-15

ok, I don't know anything about xml...

I have this XML document:
Code:
<base>
	<menu>
		<section1>Name of section1</section1>
		<section2>Name of section2</section2>
	</menu>
	<content>
		<section1>Content of section1</section1>
		<section2>Content of section2</section2>
	</content>
</base>

now, please tell me what to do.
  • how do I download the XML from to flash (at least that I think I know how to do, but just tell me, I want to be shure)
  • how do I get flash to know what all the children in <base> are
  • how do I get flash to get all the menu elements and put them in an array
  • knowing the menu elements names, how do I get flash to show on screen only one part of the content (let's say the user clicks on a part of the menu, then I want that part to show up in a text box...)

thanks

I really do find it all.
postbit arrow 17 comments | 394 views postbit arrow Reply: with Quote   
Registered User
Basta is offline
seperator
Posts: 3,713
2001-04-07
Age: 26
Basta lives in Canada
seperator

Ultrashock Member Comments:
mr-b mr-b is offline mr-b lives in United States 2001-08-15 #2 Old  
i'm in the same boat! i understand the xml part from the tutorials here on ultrashock but i am lost in flash. i can bring in asp and javascript info, but i don't understand the xml object. can someone tell us or point us to a tutorial explaining the flash part?
Reply With Quote  
miko's Avatar miko miko is offline Administrator miko lives in United States a lot of Creative Assets 2001-08-15 #3 Old  
if you guys would like to see some tutorials lemme know and we can try to put some stuff together for you
Reply With Quote  
Basta Basta is offline Basta lives in Canada 2001-08-15 #4 Old  
YES !
please do...
but the tuts would need to be about XML manipulation... ie accessing values, changing them, etc...
Reply With Quote  
cisnky cisnky is offline Moderator cisnky lives in United Kingdom 2001-08-15 #5 Old  
Get Flash 5 Studio, its all you need to get you started. they have a nice example that will get you thinking.
Reply With Quote  
Fernando's Avatar Fernando Fernando is offline Moderator Fernando lives in Peru 2001-08-15 #6 Old  
Originally posted by miko
if you guys would like to see some tutorials lemme know and we can try to put some stuff together for you
that will be cool miko...
i ahve some things (links, documents) about xml... interesting stuff.. i will email them to you later...
Fernando
Reply With Quote  
Basta Basta is offline Basta lives in Canada 2001-08-15 #7 Old  
Originally posted by cisnky
Get Flash 5 Studio, its all you need to get you started. they have a nice example that will get you thinking.

that's a book?
Reply With Quote  
cisnky cisnky is offline Moderator cisnky lives in United Kingdom 2001-08-15 #8 Old  
Basta,

Flash 5 Studio.

Friends of ED.

ISBN 1-903450-30-6

For Flash and XML go to chapter 20.

One of my best book buys along side


ActionScript:The Definitive Guide

O'REILLY: Colin Moock

ISBN 1-56592-852-0
Reply With Quote  
UberSurfer UberSurfer is offline 2001-08-15 #9 Old  
I have to agree, Actionscript: The Definitive Guide is a great book. I am currently doing a Flash/XML chapter in an upcoming book that would be useful as well.

The easiest and shortest explanation I can give is that XML is an ancestral hierarchy. That means parents have children and so forth.

<MyDoc>
<MyNode>Data</MyNode>
</MyDoc>

In that fragment, MyNode is a child node of MyDoc. Assuming you had an XML object called myDocObj pointed at MyDoc, you could do this:

myNodeObj = myDocObj.getFirstChild();

That would create a new XML doc called myNodeObj that contains only MyNode and its contents. To get the value of MyNode, you would do this:

myNodeValue = myNodeObj.getFirstChild().getNodeValue();

The reason you have to use getFirstChild again is that all textual data (not other tags) between a start and end tag is considered a text node. So you take MyNode, get its child text node then get the value of the text node. So this:

trace(myNodeValue);

Should return “Data”. This is an off-the-top-of-my-head crash course in XML. I didn’t look this up and probably missed some stuff, but it should give you a simple idea. As such, I’m not going to argue in this thread why I used getNodeValue() when I didn’t really have to… Good luck!
Reply With Quote  
Basta Basta is offline Basta lives in Canada 2001-08-16 #10 Old  
ok, thanks...
I knew about the parent/child things, but I have real problems trying to navigate through an XML file...
I'll try what you said, but could you help me out on what I'm trying to do? (ie retrieving the menu, and then according to the values in the menu, load the corresponding nodes)...

thanks

Reply With Quote  
Basta Basta is offline Basta lives in Canada 2001-08-16 #11 Old  
btw, whicch one of those books is the best for XML?
Reply With Quote  
LiQuiD LiQuiD is offline LiQuiD lives in United States 2001-08-16 #12 Old  
Isn't there an orielly XML book? I like Orielly the most personally.
Reply With Quote  
swinhoe swinhoe is offline 2001-08-16 #13 Old  
the flash bible and the macromedia site taught me..

im not the dogs b*ll*cks yet,

but if ya need soe pointers.. mail me.
Reply With Quote  
UberSurfer UberSurfer is offline 2001-08-16 #14 Old  
I have a real question then? If you know about the parent child stuff whats the problem? You just repeat as necessary to get the various data. As for books, Actionscript: The Definitive Guide has a section on XML. I don't have the FOE book so I can't say.
Reply With Quote  
Basta Basta is offline Basta lives in Canada 2001-08-16 #15 Old  
Originally posted by UberSurfer
I have a real question then? If you know about the parent child stuff whats the problem? You just repeat as necessary to get the various data
well, I can't seem to target it right...
*lol*

I'll manage...

I'll get books and look at the macromedia web site...



Originally posted by swinhoe
but if ya need soe pointers.. mail me.
shure...
mail me here...



thanks all for going out of you way to help a newbie...
Reply With Quote  
Basta Basta is offline Basta lives in Canada 2001-08-18 #16 Old  
swin?
Reply With Quote  
nik nik is offline nik lives in United States 2001-08-18 #17 Old  
i would also like to suggest you guys do one of 2 things.
either..

keep the xml in a flash friendly format .even tho we have ignorewhitespace its easier on flash if we remove the whitespace before sending the info to flash....

but that gets a bit tedius while writing the xml file so you could consider writing a php script to remove all "\t" (tabs), "\n" (newline) , "\r" (carriage return) and " " (double spaces )... call it a filter, clean script....

to make sure u do not remove intended "\n" newlines .... u can either not remove the newline or relace newlines with the "<br>" (flash html supports this) or you could URL-encode the data you store in the xml. flash lets u do this by the foll methods

escape(expression); coverts the expression to an URL-encoded string

unescape(x); does the opposite

hope that helps ya
nik
Reply With Quote  
Basta Basta is offline Basta lives in Canada 2001-08-18 #18 Old  
ok then...

Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: