PDA

View Full Version : XML-gallery with categories...



Johnsson
April 7th, 2008, 02:28 PM
Hello!

I'm trying to create an xml/flash video gallery...

this is what my XML-code looks like:



<?xml version="1.0" encoding="UTF-8"?>
<images>
<category name="Humor">
<pic>
<title>HAHA</title>
<desc>Fun...</desc>
<URL></URL>
<thumb>thumbs\004.jpg</thumb>
</pic>
<pic>
<title>HIHIHOHO</title>
<desc>lalala...</desc>
<URL></URL>
<thumb>thumbs\003.jpg</thumb>
</pic>
</category>

<category name="Music videos">
<pic>
<title>Jack Johnson</title>
<desc>Times like theese</desc>
<URL></URL>
<thumb>thumbs\002.jpg</thumb>
</pic>
<pic>
<title>Jack Johnson</title>
<desc>Times like that other time...</desc>
<URL></URL>
<thumb>thumbs\001.jpg</thumb>
</pic>
</category>
</images>




Now, here's my question...How do I trace the different values, such as category, title and so on....

Thanks:D

wvxvw
April 8th, 2008, 01:55 AM
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/XML.html
the description of XML class
http://www.ecma-international.org/publications/standards/Ecma-357.htm
whitepapers on E4X

Basicaly, text nodes are values of the properties of the parent XML object, i.e.:
if you have

<xml>
<someNode>some text</someNode>
</xml>
than

trace(xml.someNode) will output 'some text'.

Johnsson
April 8th, 2008, 07:50 AM
Hi I figured it out myself, thanks anyway!!

This is how i solved the category-issue...



xmlData.category.(@name == currentCategory).pic.URL

C:-)

doridori
April 8th, 2008, 08:48 AM
Hi I figured it out myself, thanks anyway!!

This is how i solved the category-issue...



xmlData.category.(@name == currentCategory).pic.URL
C:-)

Hi

Glad you figured it all out, and I'd like to ask a question on it.

I've kinda got the hang of basic XML and object handling but the line you wrote there interests me.

What does the (@name == currentCategory) part mean?

Johnsson
April 8th, 2008, 02:58 PM
Hi

Glad you figured it all out, and I'd like to ask a question on it.

I've kinda got the hang of basic XML and object handling but the line you wrote there interests me.

What does the (@name == currentCategory) part mean?


Hi!!

First of all currentCategory is just a variable....

If the XML is:


<category name="Humor">
<pic>
<title></title>
<desc></desc>
<URL></URL>
<thumb></thumb>
</pic>
</category>


To access the values in the "Humor" category in AS3:


xmlData.category.(@name == "Humor").pic.URL

;)

doridori
April 10th, 2008, 04:22 AM
Hi!!

First of all currentCategory is just a variable....

If the XML is:


<category name="Humor">
<pic>
<title></title>
<desc></desc>
<URL></URL>
<thumb></thumb>
</pic>
</category>


To access the values in the "Humor" category in AS3:


xmlData.category.(@name == "Humor").pic.URL
;)



Ah, I get it.
That's useful, thanks!