# Variable from xml file

**URL:** <https://forum.kirupa.com/t/variable-from-xml-file/184911>\
**Category:** Uncategorized\
**Created:** [April 9, 2006, 1:41am UTC](https://forum.kirupa.com/t/variable-from-xml-file/184911 "2006-04-09T01:41:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![igby](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/igby/32/2060_2.png) [@igby](https://forum.kirupa.com/u/igby)\
**Post date:** [April 9, 2006, 1:41am UTC](https://forum.kirupa.com/t/variable-from-xml-file/184911/1 "2006-04-09T01:41:11Z")

</div>

Here’s what I’m trying to get going:  
I have a photo gallery for a painter rotating through images via XML. She wants a little sold sign to appear on ones that have been sold. I’d like to figure out a way to make it appear/disappear with a \_visible = true/false statement that I can call from via the XML file.

Something like:  
\<node\>  
\<img\>“img.jpg”\</img\>  
\<sold\>true\</sold\>  
\</node\>  
\<node\>  
\<img\>“img2.jpg”\</img\>  
\<sold\>false\</sold\>  
\</node\>

Is this possible? I know that may not be a correct syntax, I can’t get it to work. Any Ideas? Thanks.

---

<div class="post-metadata">

**Author:** ![rciancia](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@rciancia](https://forum.kirupa.com/u/rciancia)\
**Post date:** [April 9, 2006, 2:34am UTC](https://forum.kirupa.com/t/variable-from-xml-file/184911/2 "2006-04-09T02:34:47Z")

</div>

Can you post/ send me your actionscript for his - [rcianciaruso@comcast.net](mailto:rcianciaruso@comcast.net) ? I am trying to do the photogallery which rotates thru images… and having a hard time. Regarding your question, can’t you just create an additional field in your XML file called status… and put SOLD or AVAILABLE in there… and display it ?

> [@igby](#):
>
> Here’s what I’m trying to get going:  
> I have a photo gallery for a painter rotating through images via XML. She wants a little sold sign to appear on ones that have been sold. I’d like to figure out a way to make it appear/disappear with a \_visible = true/false statement that I can call from via the XML file.
> 
> Something like:  
> \<node\>  
> \<img\>“img.jpg”\</img\>  
> \<sold\>true\</sold\>  
> \</node\>  
> \<node\>  
> \<img\>“img2.jpg”\</img\>  
> \<sold\>false\</sold\>  
> \</node\>
> 
> Is this possible? I know that may not be a correct syntax, I can’t get it to work. Any Ideas? Thanks.

---

<div class="post-metadata">

**Author:** ![devonair](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@devonair](https://forum.kirupa.com/u/devonair)\
**Post date:** [April 9, 2006, 3:57am UTC](https://forum.kirupa.com/t/variable-from-xml-file/184911/3 "2006-04-09T03:57:15Z")

</div>

Hey, Igby,

The easiest way would be to cast the value of your sold node as a string, then check its value in Flash. Something like:

xml:

```auto
 
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<!-- test.xml (booleans in xml) -->
<paintings>
 <node>
  <img>img.jpg</img>
  <sold>true</sold>
 </node>
 <node>
  <img>img2.jpg</img>
  <sold>false</sold>
 </node>
</paintings>

```

## and AS: [AS]var xml:XML = new XML(); xml.ignoreWhite = true; // xml.onLoad = function(success) { if (success) { initDisplay(this.firstChild.childNodes); } }; // function initDisplay(paintings:Array):Void { var len:Number = paintings.length; for (var i = 0; i \< len; i++) { trace(“Load: " + (paintings\*.childNodes[0].firstChild.toString())); var sold:String = paintings\*.childNodes[1].firstChild.toString(); if (sold == “true”) { trace(“make ‘sold’ movie clip visible”); } else { trace(“leave ‘sold’ movie clip be.”); } trace(”

");  
}  
}  
//  
xml.load(“test.xml”);[/AS]

---

<div class="post-metadata">

**Author:** ![igby](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/igby/32/2060_2.png) [@igby](https://forum.kirupa.com/u/igby)\
**Post date:** [April 10, 2006, 10:50pm UTC](https://forum.kirupa.com/t/variable-from-xml-file/184911/4 "2006-04-10T22:50:15Z")

</div>

Thank you devonair, that was just what I needed.
