Skip to main content
Known Participant
August 17, 2012
Answered

Please, give me an advise how to make a search of a number in xml-file (as3.0)

  • August 17, 2012
  • 2 replies
  • 3671 views

Hello! Sorry for troubling.

Please, give me an advice how to make a search of a number in xml-file (as3.0)

Thank you!

This topic has been closed for replies.
Correct answer Ned Murphy

My response was based on your question of finding numbers anywhere in the data of an xml file.  If you know the data is numeric data and the names of the nodes containing that data, then you do not have to check characters and can just check the number data using the string values....

function searchXMLFile(Event:MouseEvent):void
{
          searchDisplay.text = "";
          var pageList:XMLList = xmlFileToSearch.receipt.number;
          searchDisplay.text = "false";
   
          for (var i:int = 0; i < pageList.length(); i++)
          {

               if(pageList == searchInput.text){
                   searchDisplay.text = "true";
               }

          }
}

Even if you were looking for individual numeric characters in your previous code you would always have ended up with a false output due to have the "false" line always canceling the true line...

                              if (t.toString().indexOf(m_sSearchTerm) != -1)

                              {

                                        searchDisplay.text = "true";

                              }

                              searchDisplay.text = "false";  // this will always overwrite the textfield

2 replies

sinious
Legend
August 17, 2012

Can you post a sample of the XML and let us know where in the XML you're interested in? If you only search it as a long string then searching for the number 0, 1 or 8 can be found in the XML declaration itself:

<?xml version="1.0" encoding="utf-8" ?>

A sample of the XML would be best.

Known Participant
August 18, 2012

Thank you for advices and help, but I do not quite understand the mechanism of interaction as3.0 and xml file when the user checks, for example, your phone number in the receipt of the xml data file.

Ned Murphy
Legend
August 17, 2012

Since xml files are text files, you need to examine the individual characters in the data to see if they are numeric (0-9).

Known Participant
August 17, 2012

Thank you for your advice!

Ned Murphy wrote:

Since xml files are text files, you need to examine the individual characters in the data to see if they are numeric (0-9).