It is hardy much more work to parse the XML manually.
We did a complex search (find me all the things that a fireman might use for personal protection during an earthquake or what respirators are used by first responders or what headgear does the police marine unit wear) without XPath. Just travelled through the XML tree and applied the search criteria. We used XML to pass the search criteria as well. Nice separation between the user interface (responsible for building the search criteria) and the search engine (responsible for applying the search criteria to the XML database)

It appears that this code uses XPath to find the subtree of interest and then navigates the subtree. XPath certainly makes it clearer if the tree is complex with lots of sub-trees that are not involved in the search.
You get right to the root of the tree of interest.

Ron


Alan MacDougall wrote:
Omar Fouad wrote:
I am doing some application on flash that uses an XML file to store data... This application has a search form. I understand how to get through the xml by loops but i can't figure out how to get flash to know if this "word" is
included within the xml nodes or not... Any simple idea?
The steps would be something like this:

1. get all the nodes which might contain the word (probably as an array)
2. loop through the array, getting the string from each text node
3. use String.strpos to see if the word is present.

Which step is giving you trouble? My code would look something like this:

import com.xfactorstudio.xml.xpath.*;

function findInXML(rootNode:XMLNode, target:String):Boolean
{
   var nodeArray:Array = XPath.selectNodes(rootNode, "xpathQuery");

   for (var i:Number = 0; i < nodeArray.length; i++)
   {
      if (nodeArray[i].nodeValue.strpos(target) != -1)
      {
         return true;
      }
   }
}

And there you go. The XPath query would be something like "parentNode/childNode/text()".

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to