# AS3 returns a string with an XML node as null

**URL:** <https://forum.kirupa.com/t/as3-returns-a-string-with-an-xml-node-as-null/330723>\
**Category:** Uncategorized\
**Created:** [March 6, 2013, 7:54pm UTC](https://forum.kirupa.com/t/as3-returns-a-string-with-an-xml-node-as-null/330723 "2013-03-06T19:54:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![puppies\_amp\_pigeons](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@puppies\_amp\_pigeons](https://forum.kirupa.com/u/puppies_amp_pigeons)\
**Post date:** [March 6, 2013, 7:54pm UTC](https://forum.kirupa.com/t/as3-returns-a-string-with-an-xml-node-as-null/330723/1 "2013-03-06T19:54:18Z")

</div>

[SIZE=2]So I’m not exactly sure how to title my question, as I’m not quite sure what is the issue. . . [/SIZE]  
[SIZE=2][COLOR=#000000][FONT=Arial]I am working on a project that calls and searches an XML sheet that looks like this:  
[/FONT][/COLOR][/SIZE]

```auto
[SIZE=1][COLOR=navy][FONT=monospace]**<Searchtext Wordlookup="john smith">
**[/FONT][/COLOR][COLOR=navy][FONT=monospace]** <location>**[/FONT][/COLOR][COLOR=#333333][FONT=monospace]$1[/FONT][/COLOR][COLOR=navy][FONT=monospace]**</location>
**[/FONT][/COLOR][COLOR=navy][FONT=monospace]** <Name>**[/FONT][/COLOR][COLOR=#333333][FONT=monospace]john smith[/FONT][/COLOR][COLOR=navy][FONT=monospace]**</Name>
**[/FONT][/COLOR][COLOR=navy][FONT=monospace]** </Searchtext>**[/FONT][/COLOR][/SIZE]

```

[COLOR=#000000][FONT=Arial]and it continues like this for about 100+ people.[/FONT][/COLOR]  
[COLOR=#000000][FONT=Arial]Now, my flash takes this data and allows the user to either click on a textbox (whose e.target.data.text is matched up to the xml using @Wordlookup) or type in the name of the person (again matching the textbox’s content to @Wordlookup) which results in the location of that person lighting up (MC’s are named the same as the location node for each). This end works perfectly fine using this code:

```auto
[COLOR=#333333][FONT=monospace] var result:String = xmldata.Searchtext.(@Wordlookup == inputTxt.text.toLowerCase()).location.toString(); [/FONT][/COLOR]

```

[COLOR=#222222][FONT=Carrois Gothic]  
[/FONT][/COLOR]Now I want to do the opposite; click on a location, and the code will match up that movieclip’s name to a location in my xml, and light up that location, and output the person’s name in the textbox. Only problem in that Flash apparently thinks a node in my xml is now a variable that is undefined. I have looked high and low for a solution, but I just can’t seem to solve it (it is probably simple, and I’ll facepalm myself) The error inducing code is this:  
[COLOR=#333333][FONT=monospace]

```auto
 var resultz:String = xmldata.Searchtext.(location.text() == e.target.name).Name.toString();

```

[/FONT][/COLOR][COLOR=#222222][FONT=Carrois Gothic]  
[/FONT][/COLOR]And the error produced is this: ReferenceError: Error #1065: Variable location is not defined.  
[COLOR=#333333][FONT=adobe-clean]Here’s what I have ruled out:[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]• it’s not cause by e.target.name or e.currentTarget.name (both trace the same and correctly)[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]• it has nothing to do with my XMLloader[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]• if I make it : [FONT=monospace]var resultz:String = xmldata.Searchtext.(\*.location.text() == e.target.name).Name.toString();[/FONT][/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean] I dont have an error, but it also produces nothing, so thats not a fix.[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]•Searchtext vs. Searchfor makes no difference (SearchFor is the absolute XMl parent node)[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]•swapping my node info to being inside the “\< \>“in xml (eg: \<location @Location=”$1”\>) and changing the as3 to “…location.(@Location…” doesn’t work.[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]•the fact that AS3 recognizes location makes no difference (I have changed the name)[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]• “.toString” on or off the line of code makes no difference (I feel it might be an issue later)[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]•having “.text” after “…(location…” makes no difference.[/FONT][/COLOR]

[COLOR=#333333][FONT=adobe-clean]I feel this may rule it to be something about it’s being a string or variable? That’s all that is seemingly left…[/FONT][/COLOR]Not sure exactly why this is happening, thank you in advance for any help!  
[/FONT][/COLOR]
