Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Search XML with or without special characters

New Here ,
Nov 26, 2015 Nov 26, 2015

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!!!

TOPICS
ActionScript
304
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 26, 2015 Nov 26, 2015

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)

Translate
Community Expert ,
Nov 26, 2015 Nov 26, 2015

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 26, 2015 Nov 26, 2015

Thank glad, sometimes escape us details so simple !!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2015 Nov 26, 2015
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines