Copy link to clipboard
Copied
Hi,
Please i need your help: I have this XML:
<nodoPrincipal >
<content linkName="" url="" linkType="multi" searchableTerms="generación, vida, familia, ">
<multiLink url="cdw/day1/iAmFrom.doc"/>
<multiLink url="cdw/day1/iAmFrom.pdf"/>
</content>
<content linkName="" url="" linkType="multi" searchableTerms="casa, cama, ropa, ">
<multiLink url="cdw/day1/influences.doc"/>
<multiLink url="cdw/day1/influences.pdf"/>
</content>
<content linkName="" url="day1/Strengths.ppt" linkType="dl" searchableTerms="teléfono, celular, computación, ">
<desc><![CDATA[Strengths Finder]]></desc>
</content>
<content linkName="" url="" linkType="multi" searchableTerms="objeto, carta, mesa, ">
<multiLink url="cdw/day1/haveDoBe.doc"/>
<multiLink url="cdw/day1/haveDoBe.pdf"/>
</content>
</nodoPrincipal>
And this function to search:
//xml loaded above
function processSearchXML(xmlData:XML, searchTerm:String):XMLList
{
var searchData:XMLList = xmlData.*;
//if the node has searchable terms, add it to the list
var searchTerms:XMLList = searchData.(hasOwnProperty('@searchableTerms'));
//A list for the results
var searchResults:XMLList = new XMLList();
for each(var searchItem:XML in searchTerms)
{
//gets the attribute searchableTerms
var searchSplit:String = searchItem.@searchableTerms.toXMLString();
//builds the array of " , " seperated values
//so that I can have multiple search terms
var searchTerms_ary:Array = searchSplit.split(", ");
//A list for the results
var searchResults_ary:Array = new Array();
//trace(searchTerms_ary.length +" searchable terms in node");
//search the array
for each(var term:String in searchTerms_ary)
{
//if the record matches what I searched for, add it to the results array
if (term == searchTerm)
{
//trace(term + " has met the seach craiteria");
searchResults_ary.push(term);
}
}
//trace(searchResults_ary.length +" results in node");
//trace();
//if anything was added to the array
//add the branch to the xml list
if(searchResults_ary.length != 0)
{
searchResults += searchItem;
}
}
trace(searchResults);
return searchResults;
}
With this function I managed find whole words, but I want to search for parts of words and search with special characters such as: telƩfono or telƩ
help me plesase!!!
use indexOf instead of checking for a match if you want to retrieve parital matches. eg,
if (term.indexOf(searchTerm)>-1)
instead of
if (term == searchTerm)
Copy link to clipboard
Copied
use indexOf instead of checking for a match if you want to retrieve parital matches. eg,
if (term.indexOf(searchTerm)>-1)
instead of
if (term == searchTerm)
Copy link to clipboard
Copied
Thank glad, sometimes escape us details so simple !!!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now