# getURL from XML, PLEASE HELP

**URL:** <https://forum.kirupa.com/t/geturl-from-xml-please-help/119574>\
**Category:** Uncategorized\
**Created:** [August 16, 2004, 3:02pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574 "2004-08-16T15:02:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![uxte](https://avatars.discourse-cdn.com/v4/letter/u/278dde/32.png) [@uxte](https://forum.kirupa.com/u/uxte)\
**Post date:** [August 16, 2004, 3:02pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/1 "2004-08-16T15:02:13Z")

</div>

Hi everyone,

I’m still a newbie in flash development so I need a little help from anyone, please…

what i want to do is:

assign an action to a button that will **getURL** from a XML file (this XML being dinamically updated via PHP) from the child subnode: **\<link\>**

**my XML:**

```auto
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE data[
<!ELEMENT title (comments, image, link)>
<!ATTLIST title name CDATA #REQUIRED>
<!ELEMENT comments (#PCDATA)>
<!ELEMENT image (#PCDATA)>
<!ELEMENT link (#PCDATA)>
]>
<data>
<title name="Portégè ">
<comments>1500,00 €</comments>
<image>/prod_img/r100.jpg</image>
<link>info.php?id=60</link>
</title>
<title name="Título 111">
<comments>0,00 €</comments>
<image>image1.jpg</image>
<link>info.php?id=60</link>
</title>
<title name="Título 2">
<comments>0,00 €</comments>
<image>image1.jpg</image>
<link>info.php?id=60</link>
</title>
<title name="Título 3">
<comments>0,00 €</comments>
<image>image1.jpg</image>
<link>info.php?id=60</link>
</title>
<title name="Título 4">
<comments>0,00 €</comments>
<image>image1.jpg</image>
<link>info.php?id=60</link>
</title>
<title name="Título 5">
<comments>0,00 €</comments>
<image>image1.jpg</image>
<link>info.php?id=60</link>
</title>
</data>

```

Can anyone help?

I need the AS for this to work, please :puzzled:

---

<div class="post-metadata">

**Author:** ![Dulcinea](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@Dulcinea](https://forum.kirupa.com/u/Dulcinea)\
**Post date:** [August 17, 2004, 12:44am UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/2 "2004-08-17T00:44:02Z")

</div>

ok, first you have to pass your xml to flash  
this tutorial can tell you how:  
[http://www.kirupa.com/developer/actionscript/xmldataflash.htm](http://www.kirupa.com/developer/actionscript/xmldataflash.htm)  
then, the path you will use to get your link data cuold be:  
yourURL = yourXML.firstChild.childNodes[0].lastChild.firstChild.nodevalue;  
then, put in a button:  
on(release){  
getURL(yourURL);  
}

---

<div class="post-metadata">

**Author:** ![uxte](https://avatars.discourse-cdn.com/v4/letter/u/278dde/32.png) [@uxte](https://forum.kirupa.com/u/uxte)\
**Post date:** [August 18, 2004, 3:58pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/3 "2004-08-18T15:58:52Z")

</div>

Thank you **Dulcinea**

sorry but i’m no expert on this code stuff, so…

where should I put the path: **yourURL = yourXML.firstChild.childNodes[0].lastChild.firstChild.nodevalue;** in the flash movie? so that the button get it?

Is this a dum question?

thanks

---

<div class="post-metadata">

**Author:** ![uxte](https://avatars.discourse-cdn.com/v4/letter/u/278dde/32.png) [@uxte](https://forum.kirupa.com/u/uxte)\
**Post date:** [August 20, 2004, 12:46am UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/4 "2004-08-20T00:46:24Z")

</div>

**Dulcinea** can you help?

ppplllllllllleeeeeeeaaaassssssseeeeeeeeee

someone else???

---

<div class="post-metadata">

**Author:** ![trundrumbalind](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/trundrumbalind/32/696_2.png) [@trundrumbalind](https://forum.kirupa.com/u/trundrumbalind)\
**Post date:** [August 20, 2004, 12:12pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/5 "2004-08-20T12:12:00Z")

</div>

Put it straight after the section that loads in your XML and processes it’s contents

---

<div class="post-metadata">

**Author:** ![naderslim](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@naderslim](https://forum.kirupa.com/u/naderslim)\
**Post date:** [August 20, 2004, 12:59pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/6 "2004-08-20T12:59:05Z")

</div>

in the root timeline of the main movie, on the same frame number that the button resides, put this code:

myXml = new XML();

myXml.onLoad = function(success){  
if(success){  
\_root.myUrl = this.firstChild.childNodes[0].lastChild.firstChild.nodevalue;  
// whatever other node values you wish to bind can be put here  
//or you could redirect to another function to handle it  
}  
}

myXml.load(“myxmlsource.php”);

On your button you would then put

on (release) {

getURL(\_root.myUrl);  
}

---

<div class="post-metadata">

**Author:** ![uxte](https://avatars.discourse-cdn.com/v4/letter/u/278dde/32.png) [@uxte](https://forum.kirupa.com/u/uxte)\
**Post date:** [August 21, 2004, 5:52pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/7 "2004-08-21T17:52:38Z")

</div>

Thank you very much **naderslim** 🙂

you helped a lot

**my final Action Script**

```auto
myXml = new XML();
myXML.ignoreWhite = true;
myXML.load("destaques.xml");
myXML.ref = this;
myXml.onLoad = function(success) {
	if (success) {
		_root.firstUrl = this.firstChild.childNodes[0].lastChild.firstChild.nodevalue;
		_root.secondUrl = this.firstChild.childNodes[1].lastChild.firstChild.nodevalue;
		_root.thirdUrl = this.firstChild.childNodes[2].lastChild.firstChild.nodevalue;
		_root.fourthUrl = this.firstChild.childNodes[3].lastChild.firstChild.nodevalue;
		_root.fifthUrl = this.firstChild.childNodes[4].lastChild.firstChild.nodevalue;
		_root.sixthUrl = this.firstChild.childNodes[5].lastChild.firstChild.nodevalue;
	}
};

```

**the AS for the first button**

on (release) {  
getURL(\_root.firstUrl, “\_self”);  
}

\*\*And everything works well \>\> [you can see it here](http://teste.terazone.pt/destaques/destaques_xml.html) \*\*

**One last problem** that I have is that I need the data file to be called destaques\*\*.php\*\* instead of destaques\*\*.xml\*\* for the data base to recognize it but when I change it in the **AS** aswell as in the\*\* XML file name\*\* the flash movie seems to have trouble reading it. I have tested it locally and it works fine, but when online… doesn’t

Why is that? Can anyone help?

Thank you all that took the time to answer.

---

<div class="post-metadata">

**Author:** ![naderslim](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@naderslim](https://forum.kirupa.com/u/naderslim)\
**Post date:** [August 21, 2004, 6:00pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/8 "2004-08-21T18:00:46Z")

</div>

Hi uxte,

you cannot rename your xml file name to a php extension without the file actually being a php file. You must create a php file that posts (a string containing your xml) back to your flash file. Then you can specify xmlobj.load(myxmldata.php)…

---

<div class="post-metadata">

**Author:** ![uxte](https://avatars.discourse-cdn.com/v4/letter/u/278dde/32.png) [@uxte](https://forum.kirupa.com/u/uxte)\
**Post date:** [August 25, 2004, 4:35pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/9 "2004-08-25T16:35:44Z")

</div>

> you cannot rename your xml file name to a php extension without the file actually being a php file. You must create a php file that posts (a string containing your xml) back to your flash file. Then you can specify xmlobj.load(myxmldata.php)…

well so, why it works offline?

---

<div class="post-metadata">

**Author:** ![naderslim](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@naderslim](https://forum.kirupa.com/u/naderslim)\
**Post date:** [August 25, 2004, 4:38pm UTC](https://forum.kirupa.com/t/geturl-from-xml-please-help/119574/10 "2004-08-25T16:38:50Z")

</div>

offline, flash attempts to read loaded files as text. online your server is treating the file like a php file due to the extension…it expects a php declaration within your file…
