# Switching text/images based on URL

**URL:** <https://forum.kirupa.com/t/switching-text-images-based-on-url/215969>\
**Category:** Uncategorized\
**Created:** [February 12, 2007, 4:54pm UTC](https://forum.kirupa.com/t/switching-text-images-based-on-url/215969 "2007-02-12T16:54:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierce\_Bronkite](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@Pierce\_Bronkite](https://forum.kirupa.com/u/Pierce_Bronkite)\
**Post date:** [February 12, 2007, 4:54pm UTC](https://forum.kirupa.com/t/switching-text-images-based-on-url/215969/1 "2007-02-12T16:54:49Z")

</div>

[SIZE=2]Hey all, I was hoping someone could help me out with a bit of an Actionscript / XML issue.[/SIZE]

```auto

```

[SIZE=2]I currently have an SWF that is reading and displaying text, images and an ID number via an XML file. What I wanted to do was switch the text and graphic based on a URL.[/SIZE]

[SIZE=2]For example the if the url was [www.somedomain.com/about/](http://www.somedomain.com/about/) the SWF would then read the XML file and see that based on the domain ID the “about” text and images would load.[/SIZE]

[SIZE=2]Any idea on how I could achieve this?[/SIZE]

[SIZE=2]Thanks in advance.

Here is what my Actionscript looks like  
[/SIZE]

```auto
function loadXML(loaded) {
    if (loaded) {
        _root.headers = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
        _root.subhead = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
        _root.image = this.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;
        headline_txt.text = _root.headers;
        subheadline_txt.text = _root.subhead;
        picture_mc.loadMovie(image);
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("headers.xml");

```

[SIZE=2]

And my XML

[/SIZE]

```auto
<?xml version="1.0"?>

<headers>
    <section>
        <id>1</id>
        <title>About</title>
        <desc>A description will go here.</desc>
        <image>images/bg1.png</image>
        
    </section>    
    <section>
        <id>2</id>
        <title>Support</title>
        <desc>Another description here.</desc>
        <image>images/bg1.png</image>
        
    </section>    
</headers>

```

[SIZE=2]  
[/SIZE]
