Adobe Dreamweaver Forums



Last 10 THreads :         Embedding Flash SWF Skin in External Site (Last Post : QADesign - Replies : 0 - Views : 1 )           »          Compatible issue with ie6 (Last Post : zhtjlong - Replies : 0 - Views : 1 )           »          Re: Photoshop CS4 is a disaster (Last Post : Paulo_Skylar@adobeforums.com - Replies : 0 - Views : 1 )           »          Query question/help (Last Post : trojnfn - Replies : 2 - Views : 3 )           »          CS4 Motion Editor issues (Last Post : aaronlyon - Replies : 4 - Views : 9 )           »          Bridge No Longer Rotates Automatically (Last Post : Michael_Palumbo@adobeforums.com - Replies : 1 - Views : 2 )           »          dollarFormat / numberformat problem (Last Post : izdabye - Replies : 0 - Views : 1 )           »          Call out side flex (Last Post : Amy Blankenship - Replies : 15 - Views : 16 )           »          captions for photos (Last Post : dc111652 - Replies : 0 - Views : 1 )           »          Re: CS4 GPU Acceleration and Intel X3100 (Last Post : Paul_B_Brown@adobeforums.com - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-03-2008, 04:37 AM
New to AS3
 
Posts: n/a
Diggs:
Default Searching on XML

I want to know if there is a way to "search" on an xml file and bind that data
to a dataGrid based on that search..

basically like if you were searching through music:

<song id="0">
<title>My Song</title>
<artist>The Artist</artist>
</song>
<song id="1">
<title>Another Song</title>
<artist>The Artist</artist>
</song>
<song id="2">
<title>Disco Fever</title>
<artist>The Artist</artist>
</song>
<song id="3">
<title>Funky Guy</title>
<artist>My Artist</artist>
</song>

and then search for "song" in the song field or "The Artist" or "Artist" and
have it return anything that has those parameters in them. And if thats
possible, is it possible to search on more than one.. say all artists with
"Artist" in the field and "Song" in the title



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-03-2008, 04:37 AM
mhartnett
 
Posts: n/a
Diggs:
Default Re: Searching on XML

Put the XML into an XMLListCollection and then use the filterFunction to filter
out the data you want to see. Take a look at the api for the XMLListCollection
/ filterFunction.

here is a link that explains

http://blog.flexexamples.com/2007/08...-in-an-xmllist
collection/#more-85

Reply With Quote
  #3 (permalink)  
Old 11-03-2008, 04:37 AM
New to AS3
 
Posts: n/a
Diggs:
Default Re: Searching on XML

Thanks I'll check it out!
Reply With Quote


  #4 (permalink)  
Old 11-03-2008, 04:37 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Searching on XML


"New to AS3" <webforumsuser@macromedia.com> wrote in message
news:gdpv94$rpf$1@forums.macromedia.com...
>I want to know if there is a way to "search" on an xml file and bind that
>data
> to a dataGrid based on that search..
>
> basically like if you were searching through music:
>
> <song id="0">
> <title>My Song</title>
> <artist>The Artist</artist>
> </song>
> <song id="1">
> <title>Another Song</title>
> <artist>The Artist</artist>
> </song>
> <song id="2">
> <title>Disco Fever</title>
> <artist>The Artist</artist>
> </song>
> <song id="3">
> <title>Funky Guy</title>
> <artist>My Artist</artist>
> </song>
>
> and then search for "song" in the song field or "The Artist" or "Artist"
> and
> have it return anything that has those parameters in them. And if thats
> possible, is it possible to search on more than one.. say all artists with
> "Artist" in the field and "Song" in the title
>


http://dispatchevent.org/roger/as3-e4x-rundown/


Reply With Quote
  #5 (permalink)  
Old 11-03-2008, 04:37 AM
New to AS3
 
Posts: n/a
Diggs:
Default Re: Searching on XML

Haven't looked at the XMLListCollection yet.. but did check out the
dispatchevent link. I did get it to work with the .(node ==) method... but
here is the REALLY fun part

can anyone tell me how to do a "partial search" on a value? like in SQL:
SELECT * FROM mycol WHERE myfield LIKE '%this%'

can you do that with those methods? I can't seem to find anything that will
allow it.

Reply With Quote
  #6 (permalink)  
Old 11-03-2008, 04:37 AM
New to AS3
 
Posts: n/a
Diggs:
Default Re: Searching on XML

nevermind.. got it
musicSearchXML = music_XML.songs.song.(title.search(textSearchField .text)>-1);
Reply With Quote


  #7 (permalink)  
Old 11-03-2008, 04:37 AM
ntsiii
 
Posts: n/a
Diggs:
Default Re: Searching on XML

Also,
If you need complex calculations within an e4x expression, you can call out to
a function of your own. The () just requires a boolean value, so you can do
something like below, where I wanted to a bit of string manipulation within the
expression:

xlFilteredItems =
_xmlData..item.(itemContains(attribute("item"),sFi lterString))

and the function:
private function itemContains(sItem:String, sMatch:String):Boolean
{
sItem = sItem.toLowerCase();
sMatch = sMatch.toLowerCase();
return (sItem.indexOf(sMatch) != -1);
}//contains

Tracy


Reply With Quote
  #8 (permalink)  
Old 11-03-2008, 04:38 AM
New to AS3
 
Posts: n/a
Diggs:
Default Re: Searching on XML

Tracy,

Would this be able to work on muliple fields.. say if I wanted to search on an artist AND song title? logically it doesn't seem like it would work...
Reply With Quote
  #9 (permalink)  
Old 11-03-2008, 04:38 AM
ntsiii
 
Posts: n/a
Diggs:
Default Re: Searching on XML

Sure, that would work. Consider an expression like this:
var xl:XMLList = xml..(doMySelectionLogic(*));

I am not exactly sure that "*" is the right syntax to pass in the current
node, it might be ".", but whatever, we could figure that out.

In doMySelectionLogic(xmlCurrentContextNode:XML):Bool ean, we could use an e4x
expression to find any value anywhere in the xmlhierarchy we needed. We could
use parent().parent().. to move directly up the hierarchy. We could use
ordinary expressions to move down. We can loop over any subset we want. We
could examine global variables or any other in-scope value we wanted. We could
use Math.whatever. Anything.

Tracy



Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 03:57 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk