5 Replies Latest reply on Sep 27, 2011 5:27 AM by Amy Blankenship

    Is there any LIKE query equivalent in XML?

    r4raghs

      Is there any LIKE query equivalent in XML?

       

      I would like the display words starts with 'A' in flex list, vice versa. I send A as a input.

       

      Any ideas?

        • 1. Re: Is there any LIKE query equivalent in XML?
          miguel8312 Level 3

          As far as i know you cannot query xml with sql like statements? however i could be wrong. The way i would accomplish this would be by using an array collection and putting all my xml into that. Once i have it on the array you can simply test each item on the array for starts with 'A'.

          Hopefully that helps you.

          Miguel

          • 2. Re: Is there any LIKE query equivalent in XML?
            Peter Blazejewicz Level 4

            Hi,

             

            "starts with ..." is possible with e4x, consider below sample:

             

            - having xml

             

            var people:XML = <people>
                                                              <person firstName="Peter"/>
                                                              <person firstName="Auguste"/>
                                                              <person firstName="Gregory"/>
                                                              <person firstName="Andy"/>
                                                    </people>
            
            

            one could:

             

            var peopleWithNameStartingOnA:XMLList = people.person.(@firstName.charAt(0) == "A");
            trace(peopleWithNameStartingOnA);
            

            which should trace (and traces):

             

            <person firstName="Auguste"/>
            <person firstName="Andy"/>
            

             

            hth,

            regards,

            Peter

            1 person found this helpful
            • 3. Re: Is there any LIKE query equivalent in XML?
              r4raghs Level 1

              But I am having like below,

               

              <people>
                 <person>Peter</person>
                 <person>Auguste</person>
                 <person>Gregory</person>
                 <person>Andy</person>
              </people>

               

              needs simple modificaiton in my xml.

               

              Thanks for your time Peter.

              • 4. Re: Is there any LIKE query equivalent in XML?
                Peter Blazejewicz Level 4

                Hi,

                I don't know that one - but with slight modification I can filter nodes values also - not onlyl attributes:

                 

                var people:XML = <people>
                   <person>
                                    <firstName>Peter</firstName>
                          </person>
                   <person>
                                    <firstName>Auguste</firstName> 
                          </person>
                   <person>
                                    <firstName>Gregory</firstName>
                          </person>
                   <person>
                                    <firstName>Andy</firstName>
                          </person>
                </people>
                

                (so we have nodes that have values - not attributtes)

                and then e.g.:

                 

                var peopleList:XMLList = people.person.(firstName.charAt(0) == "A");
                trace(peopleList);
                

                (this is dynamic statement - you could replace "A" with variable reference, etc)

                 

                Edit;

                I've googled interesting article you could read on that subject here:

                http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4

                 

                hth,

                regards,

                Peter

                 

                Message was edited by: Peter Blazejewicz

                1 person found this helpful
                • 5. Re: Is there any LIKE query equivalent in XML?
                  Amy Blankenship Level 4

                  Don't forget, you can also use inStr to find nodes that have a sequence of characters as well.  Here's another great tutorial http://dispatchevent.org/roger/as3-e4x-rundown/