Is it possible to search for keywords in an XML file?

Hey all,
I'm currently searching for ways to count the number of pre-defined keywords in an XML file. An example would be trying to find how many times "war" is mentioned in a news networks RSS feed <title></title> and adding it to a variable.
I've found a few custom AS3 XML class files out there but nothing I've been able to adapt. I'm at the point of considering just taking the title of these news stories converting them all to strings and searching them that way...
I'd be grateful for any help
Thanks!

An XML element can have multiple attributes such as:
<title keyword="war" category="international">War Breaks Out in the Middle East!</title>
In the above example, the XML element <title> has 2 attributes named keyword and category.
So in my example I'm searching for the attribute named "keywords" within the element <newsItem>.
The XML document could be formatted something as the following:
============
<someNewsFeed>
     <items>
          <newsItem keyword="war" category="international" url="www.cnn.com/headline2010020111">War Breaks Out in the Middle East!</newsItem>
          <newsItem keyword="healthcare" category="politics" url="www.cnn.com/headline2010020321">Healthcare Bill Still Has Some Hurdles to Jump</newsItem>
          <newsItem keyword="lady gaga" category="entertainment" url="www.cnn.com/headline2010020981">Lady Gaga Has 360 Reach</newsItem>
     </items>
</someNewsFeed>
===========
So in my example, the if/else loop is looking through each XML node named <newsItem> and when it finds it, it then see if it has an attribute called "keyword" and if it does, it then looks to see if it contains the word "war". If it DOES, then it will do the proceeding actions.
===========
if (newsFeed.items.newsItem[q].attribute("keyword") == "war") {
          warKeywordCounter == warKeywordCounter+1; //increase your keyword counter
          trace("Current value of warKeywordCounter = "+ warKeywordCounter);
==========
I'm assuming you already know how to load external XML documents into flash.
I hope this helps.
Message was edited by: dchaparro
Corrected if/else code to include right parentheses.

Similar Messages

  • Improving Search for Keywords in NI Example Finder

    Search for Keywords is presently limited to logical "OR" search. It would highly profit from logical "AND" Search.

    Thinking out of the box here...
    It's possible to search just the bookmarks with a script. The problem is how to show the result, since it's not possible to highlight the found bookmarks.
    One option I can think of is to change the color of the matches to a different color, like red. Unfortunately, this doesn't work in Reader...
    The only other option that might work in Reader is to tell the user where to look, ie which position in the tree (and what items are before and after it).

  • Searching for Keyword

    Hi,
    Is it possible to search for a keyword in a folder which has several PDF's. For instance if i have several PDF documents in a folder. Can i search for the key word in the content of al the PDFs and display the result as the list of PDF documents which has the keyword in them.

    I think you would have to write a java application to do something like
    that.

  • Is it possible to search for multiple folders with the same name and...

    Is it possible to search for multiple folders with the same name and then select them all and change the permissions on just those folders .i.e. Search for the budget folders in all client folders and lock them down to just the project managers. Without having to go to each folder and apply the permissions.

    user11919409 wrote:
    Is it possible to create a Clone database with the same name of source db using RMAN ...
    yes
    >
    DB version is 11.2.0.2
    Is it possible to clone a 11.2.0.2 database to 11.2.0.3 home location directly on a new server . If it starts in a upgrade mode , it is ok ....yes
    Handle:     user11919409
    Status Level:     Newbie (10)
    Registered:     Dec 7, 2009
    Total Posts:     102
    Total Questions:     28 (22 unresolved)
    why do you waste time here when you rarely get any answers to your questions?

  • I have ca. 30 pdf documents I need to search for keywords; how can I do on my MAC?

    I have ca. 30 pdf documents I need to search for keywords; when I open these documents in Adobe Reader on my MAC, it shows a Search tool; however, when I search for keywords I know are in the document, none are found.  How can I do a keyword search?

    Do you know if the text has been OCR recognised? Are the original documents "scans"?
    An easy way to find out, if you can select an individual word or letter? If you are selecting a whole block of text then the document will need to be put through Optical Character Recognition (OCR) software first to enable you to keyword search.

  • Possible to Search for a Calendar

    Somehow I ended up with Calendars named "Untitled", "Untitled 2" and "Untitled 3". I don't know how these showed up and don't know what events could be associated with them. Don't want to just delete these Calendars without knowing what they have in them.
    Is it possible to search for all events within a particular Calendar? Or maybe organize/sort events by Calendar?

    smilingdog,
    Enter the " character in the iCal Search field which is located in the upper right hand corner of the iCal window. When you do that you will be presented with a results pane in the bottom of the iCal window. The results pane will have four columns at the top (Calendar/Date/Type/Title). Click on the "Calendar" column to see the results organized by specific calendars.
    Alternately, you can (⌘ + click) on any calendar in the "CALENDARS" source pane to deselect all calendars, then the calendar that you want to display, and enter the " character in the search field. That will display only the entries associated with that particular calendar.
    As a side note, the search field has a magnifying glass icon with a small down arrow which can be used to specify what items to search in.
    ;~)

  • Is it possible to search for special releasedates in the iTunesStore

    Hello,
    i'm a german musician and i want to create a song formed by a mix out of other songs released on the same day. Is it possible to search for a special releasedate, like 10.04.2012, in the iTunes Store?
    Thanks for help,
    best regards

    CrazyEyes955 wrote:
    I plan on creating a data structure of ArrayLists and would like to be able to check if I have come upon another ArrayList in the ArrayList. Perhaps the idea is illogical but this is for fun. Please offer some advice as to do so or otherwise suggest something else. Thank you.This suggests that your ArrayList will hold different types of objects. If so, I strongly urge you to reconsider this as it is fraught with dangers. Instead have your ArrayList hold only one Type of object. This type may be represented by a class, interface, enum, etc.

  • Searching for strings in a txt file

    I am writing a program based on the six degrees of seperation theory.
    Basically I have been given a (very large) txt file from the imdb with a list of all the films written in it.
    The text in the document is written like this:
    'Tis Autumn: The Search for Jackie Paris (2006)/Paris, Jackie/Moody, James (IV)/Bogdanovich, Peter/Vera, Billy/Ellison, Harlan/Newman, Barry/Whaley, Frank/Murphy, Mark (X)/Tosches, Nick (I)/Moss, Anne Marie
    (Desire) (2006)/Ruggieri, Elio/Micijevic, Irena
    .45 (2006)/Dorff, Stephen/Laresca, Vincent/Eddis, Tim/Bergschneider, Conrad/Campbell, Shawn (II)/Macfadyen, Angus/John, Suresh/Munch, Tony/Tyler, Aisha/Augustson, Nola/Greenhalgh, Dawn/Strange, Sarah/Jovovich, Milla/Hawtrey, Kay
    10 Items or Less (2006)/Ruiz, Hector Atreyu/Torres, Emiliano (II)/Parsons, Jim (II)/Freeman, Morgan (I)/Pallana, Kumar/Cannavale, Bobby/Nam, Leonardo/Hill, Jonah/Vega, Paz/Echols, Jennifer/Dudek, Anne/Berardi, Alexandra
    10 MPH (2006)/Weeks, Hunter/Armstrong, Pat (II)/Caldwell, Josh/Waisman, Alon/Keough, Johnathan F./Weeks, Gannon
    10 Tricks (2006)/Cruz, Raymond/Swetland, Paul/Selznick, Albie/Hennings, Sam/Gleason, Richard/Leake, Damien/Skipp, Beth/Ishibashi, Brittany/Thompson, Lea (I)/Jinaro, Jossara/Brink, Molly
    1001 Nights (2006)/Wright, Jeffrey (I)
    10th & Wolf (2006)/Lee, Tommy (VI)/Renfro, Brad/Ligato, Johnny/De Laurentiis, Igor/Luke Jr., Tony/Mihok, Dash/Garito, Ken/Capodice, John/Dennehy, Brian/Gullion, Jesse/Salvi, Francesco (I)/Cordek, Frank/Marsden, James (I)/Bernard, Aaron/Brennan, Patrick (VII)/O'Rourke, Ben/Gallo, Billy/Heaphy, James/Stragand, Dave/Vellozzi, Sonny/Pistone, Joe (I)/Morse, David (III)/Landis, Pete/Cain, Atticus/Trevelino, Dan/Demme, Larry/Sisto, Frank/Rosenbaum, Paul/Grimaldi, James (I)/Ribisi, Giovanni/Hopper, Dennis/Devon, Tony/Sigismondi, Barry/Kilmer, Val/Marinelli, Sonny/Cacia, Joseph/Rossi, Leo (II)/Tott, Jeffrey/Wawrzyniak, Aaron/Boombotze, Joey/Marie, Corina/Arvie, Michilline/Warren, Lesley Ann/De Laurentiis, Veronica/Moresco, Amanda/Boecker, Margot/Rossi, Rose/Latimore, Meritt/Dunlap, Doreen/Perabo, Piper/Horrell, Nickole/Sonnichsen, Ingrid
    11 Minutes Ago (2006)/Irving, Len/Welzbacher, Craig/Michaels, Ian/Dahl, Evan Lee/Gebert, Bob/Juuso, Jeremy/Hope, Trip/Green-Gaber, Renata/Dawn, Turiya/Reneau, Taryn/M
    Thats just 2 lines!
    what the program will do is take in a name (from a gui) of an actor/actress and find the smallest connection to a famous actor.
    So first things first, my idea of thinking is to search the file for K.E.V.I.N. B.A.C.O.N and all his films, and safe them into an array. Then do another search for films from the actor that the user entered at the gui. then find the shortest possible connection to both stars.
    my code for the search part of the program
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileNotFoundException;
    public class FileSearch {
         File aFile = new File("cast.06.txt");     
         FileInputStream inFile = null;
         String actor = "surname, forename"; // the person who will be the centre point e.g. kevin.bacon.
           //get the result of the actor from the gui will go here.
         public void openFilm()
              try
                  inFile = new FileInputStream(aFile);     
              catch(FileNotFoundException e)
                   System.out.println("Error");
    }The problem I have is that I can't work out how to search the txt file for a specific string/s and save them into an array. (I'm not sure if this is the best way to go about it or not at this stage).
    So whats the best way to search for an actor from that file and save the film title and the year of release?
    Hope this makes sense? what I hope the final program will be like is like this http://oracleofbacon.org/

    I went away and looked at regular expressions and this is what I came up with
    public class NameSearch{
         public static void main(String[] args)
              NameSearch ns = new NameSearch();
              ns.runIt();
         public void runIt()
              java.util.Scanner fileScan = null;
              try{
                   fileScan = new java.util.Scanner(new java.io.File("imdb.txt"));
              }catch(java.io.FileNotFoundException e)
                   e.printStackTrace();
                   System.exit(0);
              String token = null;
              String actor = "Surname, Forename";
    //real name will go in actor, left it like that for example
              while(fileScan.hasNext()){
                   token = fileScan.next();
                   Pattern pattern = Pattern.compile(actor);
                   Matcher m = pattern.matcher(token);
                   while(m.find())
                        System.out.println(m.start() + m.end());
    }This by any means not finished, I'm just trying to get to grips with regualr expressions. But when I run the program it doesn't return anything, from what I've tried to work out is it should return actor x amount of times they appear in the file. But when I run it nothing comes back (the actors name is in the text file) so I'm not too sure what I'm doing wrong, any suggestion please

  • How do I search for a word through multiple files in my directories ??

    Hello everyone
    How do I search for a word through multiple files in my directories ??
    I am guessing one tedious way to do it would be to pass all the file names as command line arguments but I"m sure there exist a much easier and faster way to do it.
    Thanks a lot

    You need to pass only the directory name as parameter and then retrieve the files(recursively throug subdirs or not, however you wish) of that directory.
    There were at least 2 threads yesterday on how to retrieve files from directory, and there are many others in the archive so I leave the search part to you ;)
    HTH
    Mike

  • I need autocomplete  for search for words in a txt. file

    i am not so good in java.
    I have a running code for search in text with a txt. file (from user bluefox815).
    But I need a solution with autocomplete for search for words in a txt. file.
    test_file.txt (Teil des Inhaltes):
    Roboter robots
    Mechatronik mechatronics
    and so on
    Can you help me please.
    Here is the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    * this program searches for a string in a text file and
    * says which line it found the string on
    public class SearchText implements ActionListener {
    private String filename = "test_file.txt";
    private JFrame frame;
    private JTextField searchField;
    private JButton searchButton;
    private JLabel lineLabel;
    private String searchFor;
    private BufferedReader in;
    public SearchText() {
    frame = new JFrame("SearchText");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    searchField = new JTextField(80);
    searchButton = new JButton("Search");
    // this is used later in our actionPerformed method
    searchButton.setActionCommand("search");
    // this sets the action listener for searchButton, which is the current class
    // because this class implements ActionListener
    searchButton.addActionListener(this);
    lineLabel = new JLabel("nach dem Fachbegriff suchen");
    public void createGUI() {
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
    JPanel bottomPanel = new JPanel();
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    topPanel.add(searchField);
    topPanel.add(searchButton);
    bottomPanel.add(lineLabel);
    mainPanel.add(topPanel);
    mainPanel.add(bottomPanel);
    frame.getContentPane().add(mainPanel);
    frame.pack();
    frame.setVisible(true);
    public void actionPerformed(ActionEvent e) {
    // now we get the action command and if it is search, then it is the button
    if ("search".equals(e.getActionCommand())) {
    searchFor = searchField.getText();
    searchTheText();
    private void searchTheText() {
    // I initialize the buffered reader here so that every time the user searches
    // then the reader will start at the beginning, instead of where it left off last time
    try {
    in = new BufferedReader(new FileReader(new File(filename)));
    } catch (IOException e) {
    String lineContent = null;
    int currentLine = 0;
    // this will be set to true if the string was found
    boolean foundString = false;
    while (true) {
    currentLine++;
    // get a line of text from the file
    try {
    lineContent = in.readLine();
    } catch (IOException e) {
    break;
    // checks to see if the file ended (in.readLine() returns null if the end is reached)
    if (lineContent == null) {
    break;
    if (lineContent.indexOf(searchFor) == -1) {
    continue;
    } else {
    lineLabel.setText(String.valueOf(lineContent));
    foundString = true;
    break;
    if (!foundString)
    lineLabel.setText("Es kann kein Fachbegriff gefunden werden.");
    try {
    in.close();
    } catch (IOException ioe) {
    public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    new SearchText().createGUI();
    }

    Markus1 wrote:
    But I need a solution with autocomplete for search for words in a txt. file.What is your question? What have you tried so far? What are you having difficulty with?
    Mel

  • Steady Stream of "Searching for movie data in the file..." Error Messages

    My iMovie has been crippled by error messages that pop up whenever I try to accomplish anything in iMovie. I always see "Searching for movie data in the file 'healyintro.mov'" for a few minutes, then "The movie file 'healyintro.mov' cannot be found. Without this file, the movie cannot play properly." I cannot actually use iMovie because of these errors.
    I've tried everything from reinstalling iMovie to removing application support files to removing my iMovie Events and iMovie Projects folders to creating a .mov file, calling it healyintro.mov and seeing if that'll shut iMovie up – nothing works.
    Once in a while, iMovie will ask for a different movie file, with the same problem.
    Any ideas?

    I am having the same issue. I don't know what the previous poster means by allowing the system to continue, since I'm prompted with a "Cancel" / "Search" dialog after each missing clip. Slight digression: "Search" is not even the correct term here according to UI guidelines ("Choose" or "Locate" might be better choices given the file picker dialog that results).
    I'm actually using Aperture to relocate my video masters on removable media, which is a very nice feature of Aperture, but completely breaks iMovie unless it's connected. Seems like a pretty major oversight.... can we just have it fail more gracefully here and allow us to work with new stuff without getting hung up on missing movie clips from the past?

  • How to do complex file search for "word" unknown characters "word" .file extension?

    How to do complex file search for "word" unknown characters "word" .file extension?

    Using spotlight in Finder helps. Do you know how to search for files in Finder?

  • Is it possible to have 2 different output config XML files and index the data into 2 endeca apps using the same indexing component ProductCatalogSimpleIndexingAdmin

    Hi ,
    We have a catalog that defines 2 types of products (they have too many different properties), so wanted to keep them on two different MDEX engines and serve the applications requests. Here DB catalog and front end ATG application is same for both the MDEX instances.
    Is it possible to have 2 different output config XML files and index the data into 2 endeca apps using the same indexing component ProductCatalogSimpleIndexingAdmin?
    Thanks
    Dev

    Hi, also have had some problem some monthes ago - I created separete component ProductCatalogSimpleIndexingAdminSecond. After that one of my colleage gave me some advice:
    The creating separate component like ProductCatalogSimpleIndexingAdmin for the second IOC is possible way for resolving your situation. But I afraid that this way will be required creating mane duplicates for already existed components.
    In my opinion the better way is the following:
    starting from AssemblerApplicationConfiguration and ApplicationConfiguration component. It contains details for connecting between ATG and Endeca. Of course you should configure different components for different Endeca Apps.
    After that:
    Find all components that uses AssemblerApplicationConfiguration and ApplicationConfiguration. Customize these components for using one or another  *Configuration component depending on what index works. (many variants released it: the most simple global custom component with flag.)
    Then customize the existed ProductCatalogSimpleIndexingAdmin. Using one or another IOC  and setting the flag in global custom component when index started. You can add some methods into your custom ProductCatalogSimpleIndexingAdmin like:
    Execute baseline index for both IOC (one by one)
    Execute baseline for IOC 1
    Execute baseline for IOC 2.
    Note: you should be afraid about incremental (partial) index in this configuration. But resolving conflicts in incremental index should be done after full implementation these changes.
    Regards

  • PDF Portfolio Search for keywords

    Hello all,
    I am trying to find out how you can search a pdf portfolio for keywords that I have added into pdf documents.
    I have added the keywords through the document properties window.
    It seems odd to be able to add keywords if you can't search for them - any help greatly appreciated
    Thanks
    Matt

    Thanks, what a bummer . I was hoping for a fix or a freeware solution :P.
    Is there a way to notify Apple about this? Keywords seem poorly designed, or at least not thought through, compared to other programs.

  • Can I search for keywords in the bookmarks only?

    For example, I have a 400 page document. There are a ton of headers which I have bookmarked each, and many have the same name - I may have 13 headers with the word "selections", yet the word "selections"  may be repeated within the document 700 tmes. My client needs to only search the bookmarks - Is that possible?

    Thinking out of the box here...
    It's possible to search just the bookmarks with a script. The problem is how to show the result, since it's not possible to highlight the found bookmarks.
    One option I can think of is to change the color of the matches to a different color, like red. Unfortunately, this doesn't work in Reader...
    The only other option that might work in Reader is to tell the user where to look, ie which position in the tree (and what items are before and after it).

Maybe you are looking for

  • I have SPDIF passthrough in Vista x

    After trying to solve this for quite a while I finally found a way to get SPDIF passthrough in Vista x64. Apparently it's been working all the time, the trick is you need to use a 64bit player. Vista is by default using the 32bit version of WMP found

  • Script for overriding category axis tick marks in graphs?

    Hello! We are introducing a new graph design, but has a problem with not being able to override the tick marks in the category axis in Illustrator CS5. A typical graph (line layout) can have 250 observations, and since we have the tick marks on full

  • Material creation with BAPI

    Hi gurús,                I am using BAPI_MATERIAL_SAVEDATA to create material. But the ejecution show the following message: 046Field WERKS has been transferred inconsistently or is blank. I really cant find where i have to charge it. I think im do i

  • 3rd Party Plug-ins won't save settings on re-open of music project

    When I'm using NI Battery 3 or Omnisphere Plug-ins they won't save the instrument setting upon re-opening my project. I'm not even using a custom setting on the instrument just a standard drum kit or omnisphere setting but when I save and close out o

  • When I try to put new items on my website on Intuit, Mozilla does not allow

    NOt only does it take ages for Mozilla to open but when I try to put new items on my website: www.carolannathan.com, I have lots of trouble.