Skip to main content
October 29, 2009
Answered

AS3 XML format question

  • October 29, 2009
  • 3 replies
  • 821 views

I'm working through a tutorial where the XML format looks like:

<image src="images/1n.jpg" name="example  1" />

The AS3 code that goes with it is:

imageText.text = xml.image[slideNum].@name.toString();

imageText.text being the dynamic text field.  This code works fine, but I'm not working with this particular format.  My XML code looks more like:

  <imgTitle>Kalamazoo</imgTitle>
<imgURL>images/1n.jpg</imgURL>

  The previous AS3 code doesn't work with this. @imgTitle.toString() does not display.  The Flash will trace the XML file for me, so I know that it's reading, but it will not fill in my dynamic text field.

Any thoughts
This topic has been closed for replies.
Correct answer

It already returns a string, and "@" is used for attributes. All you need is this:

myXML.imgTitle

3 replies

October 29, 2009

My thanks to the last two replies.  That fixed it.

I didn't realize that there were different formats for XML.  I had only ever worked with the one method.  I didn't know you could lob it all onto one line.  I probably won't ever used the line method, but it's always good to learn something new.

Thanks again for the replies

Inspiring
October 29, 2009

This is not a different format, this is a differnet elements of XML.

There is brief description of xml format

http://en.wikipedia.org/wiki/XML

October 29, 2009

Thanks for the reply.

It would make sense that XML is singular in format, I've just never seen it layed out like that before.

So if I wanted to display the images stored under the <imgURL>images/1.jpg</imgURL>, would it be movieclipName.'source' = xml.image[slideNum].imgURL; ?

Correct answer
October 29, 2009

It already returns a string, and "@" is used for attributes. All you need is this:

myXML.imgTitle

Inspiring
October 29, 2009

with @ you can get a value from attribute

in your case use .imgTitleto get the node value