# Please help, stuck with reading XML

**URL:** https://forum.kirupa.com/t/please-help-stuck-with-reading-xml/41238
**Category:** flash
**Created:** [January 26, 2004, 11:54pm UTC](https://forum.kirupa.com/t/please-help-stuck-with-reading-xml/41238 "2004-01-26T23:54:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gat](https://avatars.discourse-cdn.com/v4/letter/g/b4bc9f/32.png) [@gat](https://forum.kirupa.com/u/gat)
#### Post date: [January 26, 2004, 11:54pm UTC](https://forum.kirupa.com/t/please-help-stuck-with-reading-xml/41238/1 "2004-01-26T23:54:05Z")

</div>

Hello, I have a problem that has to be solved this week.  
I have 1 input box.  
A user will enter a feature into this box e.g “hair, fur, scales, teeth”

I then have this XML to search through.

\<?xml version=“1.0”?\>  
\<creature\>  
\<category id=“mammal” has=“hairy\_skin,mouth,warm\_blood”\>  
\<species id=“cat” has=“fur,tail,whiskers”\>  
\<breed id=“tiger” has=“stripey\_fur”/\>  
\<breed id=“lion” has=“brown\_fur,mane”/\>  
\<breed id=“panther” has=“black\_fur”/\>  
\</species\>  
\<species id=“dog” has=“hair,tail,wet\_nose”\>  
\<breed id=“labrador” has=“soft\_hair”/\>  
\</species\>  
\<species id=“pig” has=“snout,trotters”/\>  
\<species id=“cow” has=“nose,hooves”/\>  
\</category\>  
\<category id=“reptile” has=“scaly\_skin,mouth,cold\_blood”\>  
\<species id=“lizard” has=“tail,legs”\>  
\<breed id=“iguana” has=""/\>  
\</species\>  
\<species id=“snake” has=“tail,no\_legs,forked\_tongue”\>  
\<breed id=“cobra” has=“hooded\_head”\>  
\<subbreed id=“greatcobra” has=“big\_hood”/\>  
\</breed\>  
\</species\>  
\</category\>  
\<category id=“bird” has=“feathers,beak,wings,warm\_blood” /\>  
\<category id=“fish” has=“scales,mouth,cold\_blood”\>  
\<species id=“mullet” has=“thick\_lips”/\>  
\<species id=“pike” has=“sharp\_teeth”/\>  
\</category\>  
\</creature\>

If for example a user enters “Scales”  
the results need to display “fish has scales”

I have this piece of AS here that works. However it works from a different XML file.

is there any way in which this action script could be altered to search through the XML above?

[AS]  
\_global.creaturesObjects = [];  
myXml = new XML();  
myXml.ignoreWhite = true;  
myXml.onLoad = parseMe;  
myXml.Load(“creatures.xml”);

function parseMe(){  
trace(“ParseMe” + this);  
var creatures = this.firstChild.childNodes;  
trace(creatures);  
for (i=1;i\<creatures.length;i++){  
//trace(creatures\*.nodeName);  
obj = new Object();  
obj.name = creatures\*.nodeName;  
obj.isa = creatures\*.attributes.isa;  
obj.has = creatures\*.attributes.has.split(",");  
//var obj = creatures\*.attributes;  
creaturesObjects.push(obj);  
}

}  
function has(strHas){  
trace("has called: " + strHas);  
//loop through animals  
for(i in \_global.creaturesObjects){  
//loop through has properties  
for(j in \_global.creaturesObjects\*.has){  
//trace(\_global.creaturesObjects\*.name);  
if(strHas == \_global.creaturesObjects\*.has[j]){  
//trace(“found”);  
\_root.txt\_answer.text = \_root.txt\_answer.text + "  
" +  
\_global.creaturesObjects\*.name + " has " + strHas;  
}  
}  
}  
}

[/AS]  
with this on the button to submit the user input  
[AS]  
//this code goes on the button  
on(Release) {  
arrhas = new Array();  
trace(\_root.txt\_has.text);  
arrhas = txt\_has.text.split(",");  
for (i in arrhas) {  
has(\_root.arrhas\*);

```
    }

```

}  
[/AS]

i really need some help with this, any help is much appreciated  
thanks
