Is it possible to search xml embedded in flex?

Posted on 2009-04-29
Last Modified: 2012-08-14
Is it possible to have a flex document do a query?

I have a simple project for work, where the items are loaded in a product tile window and I want it to be able to search.

The file needs to live on an network drive, and be safe contained no php etc.

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

<mx:Application xmlns:mx="" layout="absolute" xmlns:ns1="*">

<mx:XML id="product">

	<product><anitem>	<itemID>	1	</itemID>	<itemName>	Light (1) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:26	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	2	</itemID>	<itemName>	Light (2) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:27	</crDate>	<isactive>	1	</isactive>	<imgURL>	</imgURL>	</anitem>

	<anitem>	<itemID>	3	</itemID>	<itemName>	Light Brown (3) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL></imgURL>	</anitem>

	<anitem>	<itemID>	4	</itemID>	<itemName>	Dark Brown (4) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	5	</itemID>	<itemName>	Tanned (5) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	6	</itemID>	<itemName>	Light Brown (6) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	7	</itemID>	<itemName>	Dark Brown (7) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>		<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	8	</itemID>	<itemName>	Tanned (8) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	100	</itemID>	<itemName>	Green Eyes (100) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	1	</isactive>		<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	101	</itemID>	<itemName>	Blue Eyes (101) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	2	</isactive>		<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	102	</itemID>	<itemName>	Brown Eyes (102) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	103	</itemID>	<itemName>	Aqua Eyes (103) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:30	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	104	</itemID>	<itemName>	Blue Eyes (104) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:30	</crDate>	<isactive>	1	</isactive>		<imgURL>		</imgURL>	</anitem>

	<anitem>	<itemID>	105	</itemID>	<itemName>	Green Eyes (105) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:30	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>




	<mx:Panel x="379" y="10" width="635" height="445" layout="absolute">

		<mx:TileList itemRenderer="ProductTile" dataProvider="{product.anitem}" x="19" y="10" width="586" height="390" rowHeight="136" columnWidth="180">




	<mx:Panel x="29" y="189" width="342" height="266" layout="absolute">

		<mx:CheckBox x="196" y="194" label="YoCash Items"/>

		<mx:Text x="10" y="20" text="Name&#x9;" width="63"/>

		<mx:TextInput x="81" y="18"/>

		<mx:Text x="10" y="55" text="Max Price" width="63"/>

		<mx:TextInput x="81" y="53" width="81"/>

		<mx:Text x="10" y="85" text="Min Price" width="63"/>

		<mx:TextInput x="81" y="83" width="81"/>

		<mx:ComboBox x="10" y="161" dataProvider="{categories.category}" width="178" id = "cat"  click="traceCat()"></mx:ComboBox>



<mx:XML id = "categories">


<category>	Swimwear (2020)  	</category>

<category>	Rugs (2008)  	</category>

<category>	Toys and Games (2035)  	</category>

<category>	Homes (2029)  	</category>

<category>	Kitchen Appliances (2022)  	</category>

<category>	Pants (100)  	</category>

<category>	Bait (2049)  	</category>




	private var txt:String;

	public function traceCat():void


		txt =cat.selectedItem.text;





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

<mx:Tile xmlns:mx="" width="180" height="136">

	<mx:Canvas width="180" height="136">



		<mx:Image x="35.5" y="24" width="60" height="60" source="{data.imgURL}"/>

		<mx:Label x="10" y="9" width="155" text ="{data.itemName}"/>

		<mx:Label x="35.5" y="97" text = "{data.price}"/>




Open in new window

Question by:cflores89
    LVL 12

    Expert Comment

    Yes, you can use XMLLists and E4X. See this:

    Author Comment

    So I would have it do my query, pass the results into an XMLLlist and then pass it into the tiles?
    LVL 12

    Accepted Solution

    Hmm .. XML object can be easily converted into an XMLList .. and .. there are nifty ways to search & filter .. see this:

    Author Comment

    Ok, I've been fiddling around with this and can't seem to get it to work.

    I had dataprovider = "{search.anitem}" for the tile and it was blank

    I then had
          var filterBy:String = "type";
           var filterValue:String = "Eyes";
           var items:XMLList;
      public function searchQuery():void
           items= product.anItem.(attribute(filterBy) == filterValue);


    so not sure to set it up correctly

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
    Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now