# Attach link to button from XML

**URL:** <https://forum.kirupa.com/t/attach-link-to-button-from-xml/313053>\
**Category:** Uncategorized\
**Created:** [August 18, 2010, 7:36pm UTC](https://forum.kirupa.com/t/attach-link-to-button-from-xml/313053 "2010-08-18T19:36:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rynobot](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@rynobot](https://forum.kirupa.com/u/rynobot)\
**Post date:** [August 18, 2010, 7:36pm UTC](https://forum.kirupa.com/t/attach-link-to-button-from-xml/313053/1 "2010-08-18T19:36:23Z")

</div>

I have an XML node: \<link\>[http://www.google.com](http://www.google.com)\</link\>  
which if that node exists will be applied to a button using the following code:

```auto
siteBtn.onRelease = function() {
			getURL(link, "_blank");
		};

```

However when i click the button it gives me an undefined address - and does not work…???

Full Code:

```auto
function loadXMLData(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		brandname = xmlNode.childNodes[0].childNodes[0].firstChild.nodeValue;
		description = xmlNode.childNodes[0].childNodes[1].firstChild.nodeValue;
		link = xmlNode.childNodes[0].childNodes[2].firstChild.nodeValue;
		brandNameTxt.htmlText = brandname;
		brandTxt.htmlText = description;
		brandTxt._width = 325;
	} else {
		brandTxt.htmlText = "Sorry, the text was unable to load.";
		trace("Could not load XML file");
	}
}
xmlFile = new XML();
xmlFile.ignoreWhite = true;
xmlFile.onLoad = loadXMLData;
xmlFile.load("brands/brand1/brand1.xml");

onEnterFrame = function () {
	if (xmlNode.childNodes[0].childNodes[2].firstChild) {
		link = xmlNode.childNodes[p].childNodes[2].firstChild;
		siteBtn._visible = true;
		siteBtn.onRelease = function() {
			getURL(link, "_blank");
		};
	} else {
		siteBtn._visible = false;
	}
};

```
