change/stylize the re ' search results for use on screen .htmlText

Hello

I am working on a search function but have a little trouble finishing some details display. The following code works very well to find and display the text in an xml file, but I want the results displayed differently.

Use the following as a source XML, I would like to:
-Put highlighted in red (var searchTerm) search term when found in the xml file
-Add a few characters before and after the search term to give the term found little context

For now, how could I add 3 characters before and after the search term, as follows: "The first tex" - and highlight 'first' in red?

Thanks much for any help.
~ chipleh

var xmlFileToSearch:XML = 
<xml>
     <sim>    
          <bodyText>
               <page number="0">        
                    <para><![CDATA[The first text to search]]></para>
               </page>
               <page number="1">
                    <para><![CDATA[The 2nd text to search]]></para>
               </page>
               <page number="2">
                    <para><![CDATA[The 3rd text to search]]></para>
               </page>
               <page number="3">
                    <para><![CDATA[The 4th text to search]]></para>
               </page>
          </bodyText>
     </sim>
</xml>
;

function searchXMLFile():void
{            
     var xmlBody:XML = xmlFileToSearch.sim.bodyText[0];
     var pageList:XMLList = xmlBody.page; 
     //String to search for
     var searchTerm:String = "first";  
     for (var i:int = 0; i < pageList.length(); i++)
     {  
          var item:XML = pageList[i];
          var textList:XMLList = item.para.text();    
          for (var j:int = 0; j < textList.length(); j++)
         {   
               var t:XML = textList[j];   
               //if the string is found
               if (t.toString().toLowerCase().indexOf(searchTerm.toLowerCase()) != -1)
               {      
                    //traces "Page 1. - The first text to search"
                    trace("Page " + (Number(item.attributes())+1) +". - "+t.toString());
                    //How could I add 3 characters before and after the search term, like so: "The first tex" 
                    //- and highlight 'first' in red?   
                    searchDisplay.htmlText += ("Page " + (Number(item.attributes())+1) +". - "+t.toString());            
               }   
          } 
     }
}

searchXMLFile();


t.substring(t.indexOf(searchTerm) - 4, t.indexOf(searchTerm)) + "" + searchTerm + "" + t.substr(t.indexOf(searchTerm) + searchTerm.length, 4);

Tags: Adobe Animate

Similar Questions

  • Thumbnail images in the Google search results? (Using Adobe Muse)

    Hello

    I've been hunting around a large number of pages (including the webmaster tools) my question is simple, but the answers seem not to be!

    Someone at - it an easy and quick way, adding a thumbnail that will appear next to a site search result in Google?

    Obviously, this is a site designed and downloaded directly from the Adobe Muse.

    Some tips would be much appreciated!

    Thank you

    That is entirely up to Google and like so many things depends on your ranking and if / or send you your money.

    Mylenium

  • Numbering of the GREP search result

    Hi all

    I am trying to apply some paragraph styles to various items in my document, but rather than static reference to the paragraphs in question (whose position can be subject to change in the future), I try to do a GREP search result-based. The chapters follow the same structure, with a subtitle of chapter ("Chapter 1, Chapter 2, and so on"), followed by a paragraph with the title of the chapter, followed by the first paragraph of the body.

    Now, it is easy for me to find the chapter number using a GREP search, and I would like to know if it is possible for me to read the number of paragraph of this search result. In this way, I can start the paragraph numbers of the remaining items on their position relative to the subheading and then apply the styles to paragraph appropriate for them.

    All the best and thanks in advance,

    Julian

    p.s.: as a reference, this is the result of the search:

    
    
    
    
    // Find chapter subheading and apply
    
    
    
    app.findGrepPreferences = app.changeGrepPreferences = null;
    
    
    
    app.findGrepPreferences.findWhat = "(?i)Hoofdstuk \w*\r";
    
    
    
    var myStartLine = myDocument.findGrep(); // Save search result for future reference as a first line
    
    
    
    app.changeGrepPreferences.appliedParagraphStyle = myPGS_CS ;
    
    
    
    myDocument.changeGrep();
    
    
    
    

    Just another idea: If you can find your first paragraph apply the paragraph style, and then loop through all paragraphs in the document and compare the name of the applied style. If you found one, the next paragraph is the current a + 1, the second is the current a + 2.

    var curDoc = app.activeDocument;
    
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "Head \\d\\r";
    app.changeGrepPreferences.appliedParagraphStyle = "h1";
    
    var startLine = curDoc.findGrep();
    curDoc.changeGrep();
    
    var allParas = curDoc.stories.everyItem().paragraphs.everyItem().getElements();
    
    for ( var p = 0; p < allParas.length; p++ ) {
        var pStyleName = allParas[p].appliedParagraphStyle.name;
        if ( pStyleName == "h1" ) {
            allParas[p+1].appliedParagraphStyle = "p1";
            allParas[p+2].appliedParagraphStyle = "p2";
        }
    }
    

  • When I right click on an image, I can't see the option "search Google for this image. How can I get that back?

    I don't know what that I have maybe changed, but right-click on any image, gave me the option in the Google search menu for the image. This option is gone.

    This is not a built-in feature. Have you used any of these extensions:

    You might first check the addons page to ensure that it is not disabled. Either:

    • CTRL + SHIFT + a
    • "3-bar" menu button (or tools) > Add-ons

    In the left column, click Extensions. On the right side, off the cluster of extensions at the bottom.

    If it is enabled, it could be a problem with some of the code in the extension is not compatible with Firefox 40, or one other extension it bumping from the context menu.

  • column of file missing in the bookmarks search results

    In the library of all bookmarks page, when you search for bookmarks, the returned list does not record information. When I find dead links, I would go to this bookmark folder to see if there are any more stale bookmarks that are. I guess that more people use tags as the folders and subfolders to sort their bookmarks? For example, under Science, I have astronomy, physics, etc.

    column of file missing in the bookmarks search results

    Install the "Show Parent folder" and (also useful) extensions "Go Parent Folder" for what you want, you want to really read the knowledge base article.

    Sorting and rearranging bookmarks - Firefox (and in collaboration with bookmarks)
    http://KB.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox

    For more information about the extensions I use, see

    http://dmcritchie.MVPs.org/Firefox/Firefox.htm#ext_table
    For more information on keywords shortcuts, see

    http://dmcritchie.MVPs.org/Firefox/KWS.htm

    If it solves your problem, please mark it as resolved.

  • Request OA region shows the previous search results when moving between pages

    Hi all

    I have a custom Page of OA, which is a query based on a LOV region to search for names of devices. The problem I am facing is once the device name is searched and I'm going to another page through quick links and back on the same page Search Device, it shows the previous search results. I am does not keep AM for all navigation page.

    I already tried things:
    4 K I tried refreshing VO using clearcache and reset methods on the VO.
    2 get, click on the OK button of the query in ProcessFormRequest region and the Go button I use forwardImmediatelyToCurrentPage. And in the process request method that I question the results manually when will click on a button. Otherwise I do it manually where clause condition 1 = 2 and ensure that the VO returns no rows.

    But still, I am not able to get rid of the issue.

    The used code is pasted below for your reference. It is urgent. Can you please provide pointers.


    ' Public Sub processRequest (pageContext OAPageContext, OAWebBean webBean)
    {
    super.processRequest (pageContext, webBean);
    Try
    {
    Am = (VpaAdminAMImpl) pageContext.getApplicationModule (webBean) VpaAdminAMImpl;
    TkvpaDeviceSearchVOImpl deviceAll = am.getTkvpaDeviceSearchVO1 ();

    deviceAll.clearCache ();
    deviceAll.reset ();
    deviceAll.setWhereClause ("1 = 2");
    deviceAll.setWhereClauseParams (null);
    String query = deviceAll.getQuery ();
    System.out.println ("request getSearchResult: =" + query);
    deviceAll.executeQuery ();

    OAQueryBean queryBean = (OAQueryBean) webBean.findChildRecursive ("region1");
    String goAction = queryBean.getGoButtonName ();
    If (PageContext.GetParameter (goAction)! = null)
    {
    getSearchResult (pageContext, am, webBean);
    }
    }
    catch (Exception ex)
    {
    throwException ("SearchDeviceCO.processRequest", ex);
    }
    }


    ' Public Sub processFormRequest (pageContext OAPageContext, OAWebBean webBean)
    {
    super.processFormRequest (pageContext, webBean);
    Action string = pageContext.getParameter (EVENT_PARAM);
    OAQueryBean queryBean = (OAQueryBean) webBean.findChildRecursive ("region1");
    String Go = queryBean.getGoButtonName ();
    System.out.println (PageContext.GetParameter (Go));

    If (PageContext.GetParameter (GB)! = null)
    {
    pageContext.forwardImmediatelyToCurrentPage (null, false, "N");
    }
    }

    Public Sub (VpaAdminAMImpl am, pageContext, OAWebBean webBean OAPageContext) getSearchResult
    {
    Try
    {
    String device = pageContext.getParameter ("deviceSearch");

    StringBuffer sb = new StringBuffer();
    If (device! = null & & device! = "")
    {
    SB. Append ("nom_peripherique =" "");
    SB. Append (Device);
    SB. Append("'");
    }

    String sql = sb.toString ();
    TkvpaDeviceSearchVOImpl deviceAll = am.getTkvpaDeviceSearchVO1 ();
    deviceAll.setWhereClause (sql);
    deviceAll.setWhereClauseParams (null);
    String query = deviceAll.getQuery ();
    System.out.println ("request getSearchResult: =" + query);
    deviceAll.executeQuery ();
    } catch (System.Exception e)
    {
    e.printStackTrace ();
    }
    }


    Thanks in advance,
    Abhishek Mishra

    Hi Abhishek,

    Please try the code below in your controller ProcessRequest
    This will clear the previous search from the cache.
    Example of
    OAQueryBean queryBean = (OAQueryBean) webBean.findChildRecursive ("QueryRegionName");
    queryBean.clearSearchPersistenceCache (pageContext);

    Hope that helps :-)

    Kind regards
    Chaouki

  • Link to shift + click on the Google search result

    How can I open new tab/windows by link shift + click on the Google search results?

    It is the way in which Firefox opens the link.

    My current setting is Ctrl + click opens a new tab in a new background tab, shift + click opens the link on the same page.

    Firefox 40.0.3 Windows XP

    For the Google site, you can set preferences on the Google page via the top gear icon to the right of the results, click this button to open the list of menu and select search parameters.

    Where results open: Open search results in a new browser window.
    

    Google settings are stored in a PREF cookie on your computer, you must create an exception to allow him to keep cookies for Google to save settings, otherwise you will have to repeat.

  • Risks and impacts on the changes in the physical and logical structures used in ODI

    What are the risks and impacts on the changes in the physical and logical structures used in ODI?


    I wonder what can be changed and the risks and impacts that may occur changes in the physical and logical structures used in projects of ODI?

    You should not change the name of logic. Because in ODI, each model is connected to a logic diagram.
    You shouldn't be changing technology too because that would need a change to all models and the KMs that have been used in the development of interfaces and procedures, etc.

    Nothing under the physical schema can be changed for example. Connection, user, etc.
    ODI uses the logical schema. And it matches the physical schema in the runtime using contexts.

  • What is the best HDMI switch for use with Apple tv 4

    What is the best HDMI switch for use with Apple tv 4. I heard some do not work and the automatic switch has problems because Apple tv is still using power?

    I installed on a cutting and not because the automatic switch works because it isn't always. It came with a remote control that is almost as good, so don't mind the fact that automatic switching does not work well. The reason why I chose cutting is because it was the first device that gave me the good picture and sound quality with my AppleTV, the Xbox 360 and the PS4. (Don't ask!)

  • Any camera regardless of the interface is available for use with the LabView interface.

    Hello

    I intend to go for some CMOS camera,

    but I have a huge doubt before buying, the camera of menttioned above is not anywhere in this list. Nor can I see any type being supported USB device.

    The question is

    1. is a camera regardless of the interface is available for use with the LabView interface?
    2. Can I build a VI to communicate with any device image and recording of camera and take the data?

    Any kind of help or advice is greatly appreciated... I have to buy a CMOS camera and begin to run.

    Thank you...

    Hello Virginia,.

    I am pleased that this information has been useful, one thing I wanted to mention is that USB 3.0 has its own standard USB 3.0 Vision which is currently not supported. If this camera is also Direct Show compatible then you will be able to acquire an image using IMAQdx and manipulate all the attributes that are published to the API Live Show.

    I hope that USB 3.0 Vision will be supported in the near future, and we tentatively announced for this standard of communication for the August 2013 Vision Acquisition Softwareupdate.

    See you soon,.

    -Joel

  • Please give me the html code ready for use

    Dear Sir

    Please give me the html code ready for use

    Yes, we know now, it's the Telugu ;-) In any case, the subject of the question is not in this forum.

  • Windows 7 does not recognize me as an administrator and do not make changes to the notifier of explicit congestion using cmd

    Windows 7 does not recognize me as an administrator and do not make changes to the notifier of explicit congestion using cmd

    I am the administrator also have an account invited and created another user account to see if this helped (she didn't)

    Hello

    If you use the command prompt, you must bring up the command prompt.

    Go in Start / All Programs / Accessories.

    Click on the command prompt and select run as administrator .

    Concerning

  • How can I prevent the text fields and drop downs changed after the form has been signed using a digital certificate? Thank you.

    Hi all

    How can I prevent the text fields and drop downs changed after the form has been signed using a digital certificate? Thank you.

    There is also a checkbox on the dialog box 'Sign' to lock document after signing.

  • How can I increase the frames of number for all images (screen time).

    I have a slideshow in adobe elements 13 with 650 photos first.  After addinig "in/out fad" photos are not on screen long enough.  How can I increase the frames of number for all images (screen time).  There are currently over 90, and I turn to 150 executives.

    ludhianvi

    What version of Premiere Elements you are using and on what computer operating system is running?

    From your description of a term still image, you seem to be looking at the setting still Image default duration in Edit Menu/preferences/general.

    This parameter is used so that all the still images imported AFTER the game is done will be important in this project with whatever the setting. The unit for the adjustment is images. The default is 150 images (the equivalent of 5 seconds in a 30 frames per second). What you are telling us that the setting is currently 90 images (3 seconds) and you want to return to 150 senior (5 seconds). Once again, callback, which is for all images imported into the project ONCE defined.

    To avoid resetting it and re - import still images, you can adjust the length of image yet at the level of the timeline. This that you do, it will not change the Edit Menu/Settings/general still Image default duration = 90 images project which emerged these preferences settings.

    At the level of the timeline, select all images whose duration is from 3 to 5 seconds. Right-click anywhere in the selection, select Time Stretch.

    Duration of the Time Stretch 00 change dialog box. 00; 03; 00 00; 00; 05; 00 (hours, minutes, seconds; images).

    According to the position of the circumstances or a parent of the always involved, select it all is possible

    a. edit Menu/select all

    or

    b. using the mouse to draw a rectangle autour clips concerned to select

    or

    c. press and hold the SHIFT key on the main keyboard to the computer and clicking on each of the items.

    Please review and consider. If any questions or need any clarification, do not hesitate to ask.

    Thank you.

    RTA

  • I want to erase the search results for certain searches. When I search for some keywords I get old SERPs that I know are not up-to-date. If I use a different machine, I get the current results. I can't find how to clear it.

    I am tracking my own Web site position in search rankings. For a short period, he appeared on page 1 for certain keywords. It is now on page 2 or 3, (as seen by me and other users when you use another computer or a browser), but when I search on my computer I see the old pages of results showing the top of page 1. How can I erase these old pages of results?

    If you press Ctrl and F5 at the same time, that changes? I think that Google (I guess that's what you're referring to the) changes in search results is inspired by a little if you are connected and preferences, etc.. Try to connect on google if you are connected.

Maybe you are looking for

  • Send videos uploaded from your phone

    I have an I Phone 5 s. I love him because he makes so many things. I use it to take pictures and videos frequently and there are times when I'm not able to send a video that I took with my phone to someone without receiving an error message "the vide

  • You have to have a pro to use the pencil of the apple iPad, or can you have a regular iPad?

    You have to have an iPad Air to use the pencil of the Apple, or can you have a regular iPad?

  • D7160 on OSX 10.9.3

    Just installed 10.9.3 this morning, now, the printer does not seem to be communication.   Printer preferences show that it is the default printer.  When I tried to print (several times), I get the message Order - failure to "Filter", 1 page What's ne

  • Problem loading battery Camileo H20

    I bought a charger mobile expensave that plugs into the 12v car power socket to recharge the camcorder while on the move. The charger has a taken USB port that delivers 5V @ 2A of load. No matter how long the camcorder is connected, the battery light

  • Error 646 times

    Whenever I try to install some Windows updates, I get this error message.  I tried to install each update separately, all failed.  They are the following: (KB978380, KB981433, KB978382, KB981715).  All 4 are updates of security for Excel, Office and