# Targeting a XML element from AS2

**URL:** https://forum.kirupa.com/t/targeting-a-xml-element-from-as2/294202
**Category:** Uncategorized
**Created:** [August 10, 2009, 8:35pm UTC](https://forum.kirupa.com/t/targeting-a-xml-element-from-as2/294202 "2009-08-10T20:35:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Offrenbaruna](https://avatars.discourse-cdn.com/v4/letter/o/7cd45c/32.png) [@Offrenbaruna](https://forum.kirupa.com/u/Offrenbaruna)
#### Post date: [August 10, 2009, 8:35pm UTC](https://forum.kirupa.com/t/targeting-a-xml-element-from-as2/294202/1 "2009-08-10T20:35:05Z")

</div>

Hello again forum, I’m still working in flash/XML project and every time I have a question about it, now it went very deep and the answer of this question is my only alternative.

ok. so I have my XML document which I load in flash, now in flash I want to scope a spescific tag of my xml document with a variable.

```php

<?xml version="1.0" encoding="utf-8"?>
<company>
    <marketing>
        <employeeOffice>
            <employee name="employee1" salary = "1000"/>
            <employee name="employee2" salary = "1100"/>
            <employee name="employee3" salary = "1200"/>
            <employee name="employee4" salary = "1300"/>
            <employee name="employee5" salary = "1400"/>
        </employeeOffice>
        <employeeRoad>
            <employee name="employee1" salary = "1000"/>
            <employee name="employee2" salary = "1100"/>
            <employee name="employee3" salary = "1200"/>
            <employee name="employee4" salary = "1300"/>
            <employee name="employee5" salary = "1400"/>
        </employeeRoad>
    </marketing>
    <production>
        <employeeOffice>
            <employee name="employee1" salary = "1000"/>
            <employee name="employee2" salary = "1100"/>
            <employee name="employee3" salary = "1200"/>
            <employee name="employee4" salary = "1300"/>
            <employee name="employee5" salary = "1400"/>
        </employeeOffice>
        <employeeRoad>
            <employee name="employee1" salary = "1000"/>
            <employee name="employee2" salary = "1100"/>
            <employee name="employee3" salary = "1200"/>
            <employee name="employee4" salary = "1300"/>
            <employee name="employee5" salary = "1400"/>
        </employeeRoad>
    </production>
    <sales>
        <employeeOffice>
            <employee name="employee1" salary = "1000"/>
            <employee name="employee2" salary = "1100"/>
            <employee name="employee3" salary = "1200"/>
            <employee name="employee4" salary = "1300"/>
            <employee name="employee5" salary = "1400"/>
        </employeeOffice>
        <employeeRoad>
            <employee name="employee1" salary = "1000"/>
            <employee name="employee2" salary = "1100"/>
            <employee name="employee3" salary = "1200"/>
            <employee name="employee4" salary = "1300"/>
            <employee name="employee5" salary = "1400"/>
        </employeeRoad>
    </sales>    
</company>

```

Let’s say that my var is

```php
var whichDepartment = marketing;

```

and from there I can target departement and then look for the information that is within this XML element.

I know that this is not possible in AS2 and I want to know if there is some way to get something similar…

```php
var whichDepartment_01= myXML.firstChild.whichDepartmen.childNodes.nodesName;

```

Any help will be appreciated 🙂
