XML search

I know there are a lot of threads on the forums about this but most just point to senocular’s tutorial. So I read through it and I hate copying a tutorial so I am attempting to recreate it but I am having some problem.

I have a text field, button, and display. I can post/receive from them on click. The problem is when I try to actually match my input to my xml. It doesn’t work. Here is what senocular does:

SearchXML = function(nodes, query, useChildElements){
var results = [];
for (var i=0; i<nodes.length; i++){
for (var j=0; j<nodes*.childNodes.length; j++){
currNode = nodes*.childNodes[j];if (useChildElements.contains                           (currNode.nodeName)){
if    (currNode.firstChild.nodeValue.contains(query)){
results.push(nodes*);break;}}}}
return results;}

Here he uses contain to see if the query matches the XML. So I figured I’d try the same but it doesn’t work. Here’s mine

var content_XML:XML = new XML();
content_XML.ignoreWhite = true;
content_XML.onLoad = function(success){
    if (success){
        inputSearch._visible = true;
    }else{ 
        resultsTxt.text = "Error loading XML";
    }
}
inputSearch._visible = false;
content_XML.load("search.xml");

btnSearch.onRelease = function(){
    if(inputSearch.text.length < 3){
        resultsTxt.text = "Your query is too short. Please try another one.";
        return(0);
    }
    for(i=0;i<content_XML.firstChild.childNodes.length;i++){            
        if(content_XML.firstChild.childNodes*.firstChild.nodeValue.contains (inputSearch.text)){
            trace("YAY");
        }
    }
}

All I’m trying to do there is get it to trace yay, but that won’t even work.

If my XML is needed here it is also:

<root>
    <i id="1">
    Soup fish cat dog nuts meow kitty kitty
    </i>
    <i id="2">
    Hell heaven satan god lucifer angel demon bliss pain
    </i>
</root>

Any help would be wonderful :slight_smile: