The e4XParser I speak of is at: 
http://www.adobe.com/devnet/flex/articles/e4x_04.html



--- In flexcoders@yahoogroups.com, "Jim Hayes" <[EMAIL PROTECTED]> wrote:
>
> >I've already included some
> >dynamic e4x expression parsers that I found on the web
> 
> Tod, 
> 
> do you have the urls for those to hand? and would you care to share
them?
> Sorry to be so lazy, but I use e4x occasionally enough for the
syntax to generally escape me when I have to.
> Hence anything I can bookmark for the next time I need a bit of help
with it would be most useful to me (and others?)
> 
> many thanks,
> 
> Jim.
> 
> 
> -----Original Message-----
> From: flexcoders@yahoogroups.com on behalf of Todd
> Sent: Wed 16/01/2008 22:51
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] E4X Namespace Issues...
>  
> I'm sure this will have an obvious answer and that it's something that
> I've just been looking at for too long...
> 
> I'm trying to select a node from xml where a child has a specific value
> For example:
> var xml:XML =
> <communication xmlns="stuffHERE">
> <folder>
> <id>1</id>
> <folder>
> <id>2</id>
> </folder>
> <folder>
> <id>3</id>
> <folder>
> <id>4</id>
> </folder>
> </folder>
> </folder>
> 
> In the above, I'm using an e4x expression that looks like:
> xml..folder.(id == 3)
> 
> All works well when I don't have a namespace declared.
> When I have a name space declared, I keep getting nothing back.
> I'm using the actionscript object:  namespace test="http..."
>                                     use namespace test
> 
> Any ideas on what I'm doing wrong? BTW, I've tried many, many
> different e4x expressions, none that work.
> 
> Also, any techniques for debugging e4x? I've already included some
> dynamic e4x expression parsers that I found on the web. But I find
> that while I can get the expression to work fine dynamically, it still
> doesn't work.
> 
> I've posted this over in teh Adobe Forums, too, as I'm not really sure
> which place is the best place to go for help.
> 
> Thanks a bunch
> 
> Here's my test MXML file, sorry for how ugly it looks in this window.,
> I"m hoping you can just copy this and paste it into a new MXML file
> for you to look at...:
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="horizontal">
>       <mx:Script>
>               <![CDATA[
>                       import mx.logging.targets.TraceTarget;
>                       import com.theriabook.util.logging.TraceLogOutput;
>               private var comm:XML = 
> <CommunicationHierarchy
>
xmlns="http://www.directTestmarketing.com/ws/schemas/communicationHierarchyService";>
>      <folder>
>         <id>13</id>
>         <recordType>FOLDER</recordType>
>         <iconId>icon id</iconId>
>         <label>label</label>
>         <shortDescription>short description</shortDescription>
>         <description>Folder 21 description</description>
>         <externalId>1</externalId>
>         <template>
>            <id>21</id>
>            <recordType>TEMPLATE</recordType>
>            <iconId>icon id</iconId>
>            <label>label</label>
>            <shortDescription>short description</shortDescription>
>            <description>Template 22 description</description>
>            <externalId>1</externalId>
>         </template>
>         <folder>
>            <id>14</id>
>            <recordType>FOLDER</recordType>
>            <iconId>icon id</iconId>
>            <label>label</label>
>            <shortDescription>short description</shortDescription>
>            <description>Folder 31 description</description>
>            <externalId>1</externalId>
>            <link>
>               <id>13</id>
>               <recordType>TEMPLATE</recordType>
>               <iconId>icon id</iconId>
>               <label>link label</label>
>               <url>link url</url>
>               <shortDescription>short description</shortDescription>
>               <description>description of link - 14</description>
>            </link>
>         </folder>
>         <folder>
>            <id>15</id>
>            <recordType>FOLDER</recordType>
>            <iconId>icon id</iconId>
>            <label>label</label>
>            <shortDescription>short description</shortDescription>
>            <description>Folder 36 description</description>
>            <externalId>1</externalId>
>            <link>
>               <id>15</id>
>               <recordType>TEMPLATE</recordType>
>               <iconId>icon id</iconId>
>               <label>link label</label>
>               <url>link url</url>
>               <shortDescription>short description</shortDescription>
>               <description>description of link - 16</description>
>            </link>
>         </folder>
>         <link>
>            <id>8</id>
>            <recordType>TEMPLATE</recordType>
>            <iconId>icon id</iconId>
>            <label>link label</label>
>            <url>link url</url>
>            <shortDescription>short description</shortDescription>
>            <description>description of link - 9</description>
>         </link>
>         <link>
>            <id>12</id>
>            <recordType>TEMPLATE</recordType>
>            <iconId>icon id</iconId>
>            <label>link label</label>
>            <url>link url</url>
>            <shortDescription>short description</shortDescription>
>            <description>description of link - 13</description>
>         </link>
>      </folder>
>      <template>
>         <id>44</id>
>         <recordType>TEMPLATE</recordType>
>         <iconId>icon id</iconId>
>         <label>label</label>
>         <shortDescription>short description</shortDescription>
>         <description>Template 45 description</description>
>         <externalId>1</externalId>
>      </template>
>      <template>
>         <id>45</id>
>         <recordType>TEMPLATE</recordType>
>         <iconId>icon id</iconId>
>         <label>label</label>
>         <shortDescription>short description</shortDescription>
>         <description>Template 46 description</description>
>         <externalId>1</externalId>
>      </template>
>   </CommunicationHierarchy>
>       
>               private namespace directTest =
>
"http://www.directTestmarketing.com/ws/schemas/communicationHierarchyService";;
>                       use namespace directTest;
>                       
>                       public var directTest2:Namespace = new
>
Namespace("http://www.directTestmarketing.com/ws/schemas/communicationHierarchyService";);
>             
>                       private function onGoClick(e:MouseEvent):void
>                       {
>                                                       
>                               use namespace directTest;
>                               var xml:XML = new XML(inputXML.text);
>                               
>                               //      All these filters didn't work:
>                               //      new XMLList(xml..folder.(id ==13));
>                               //  new XMLList(xml..folder.("id" =="13"));
>                               //
>                               //
>                               //
>                               //
>                               //
>                               //      These Worked:
>                               //              new XMLList(xml.folder[0]) 
>                               //              new XMLList(xml..folder.(id == 
> 13));
>                               //              new 
> XMLList(xml.descendants("folder").(id == 13));
>                               //
>                               
>                               //var filterdXML:XMLList = new 
> XMLList(directTest2::folder.(id ==
> 13));
>                               var filterdXML:XMLList = new 
> XMLList(xml.descendants("folder").(id
> == 13));
>                               outputXML.text = filterdXML.toXMLString();
>                       }
>                       
>               ]]>
>       </mx:Script>
>       <mx:TraceTarget level="0" />
>       <mx:TextArea id="inputXML" width="100%" height="100%"
> text="{comm.toXMLString()}"/>
>       <mx:Button id="go" click="onGoClick(event)" />
>       <mx:TextArea id="outputXML" width="100%" height="100%" />
>       
>       
> </mx:Application>
> 
> 
> 
> 
> ______________________________________________________________________
> This communication is from Primal Pictures Ltd., a company
registered in England and Wales with registration No. 02622298 and
registered office: 4th Floor, Tennyson House, 159-165 Great Portland
Street, London, W1W 5PA, UK. VAT registration No. 648874577.
> 
> This e-mail is confidential and may be privileged. It may be read,
copied and used only by the intended recipient. If you have received
it in error, please contact the sender immediately by return e-mail or
by telephoning +44(0)20 7637 1010. Please then delete the e-mail and
do not disclose its contents to any person.
> This email has been scanned for Primal Pictures by the MessageLabs
Email Security System.
> ______________________________________________________________________
>


Reply via email to