A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: E4X trouble. Any way to match child node value and get XMLList several nodes up?

  1. #1

    E4X trouble. Any way to match child node value and get XMLList several nodes up?

    Using this simplified example, is there a way to match the description DESC4 and spit out an XMLList at the module level? Right now it spits it out at the activity level. The end goal is to search on "DESC4" and spit out "MODULE2" but I doubt that's possible. I do not want to use looping as I'm dealing with thousands of lines of XML. (not my idea!) If anyone has any idea please let me know!

    var data:XML =
    Code:
    	<modules>
    		<module>
    			<modName><![CDATA[MODULE1]]></modName>
    			<activityList>
    				<activity>
    					<description><![CDATA[DESC1]]></description>
    				</activity>
    				<activity>
    					<description><![CDATA[DESC2]]></description>
    				</activity>
    			</activityList>
    		</module>
    		<module>
    			<modName><![CDATA[MODULE2]]></modName>
    			<activityList>
    				<activity>
    					<description><![CDATA[DESC3]]></description>
    				</activity>
    				<activity>
    					<description><![CDATA[DESC4]]></description>
    				</activity>
    			</activityList>
    		</module>
    	</modules>;
    
    var newList:XMLList = data.module.activityList.activity.(description.text() == "DESC4");
    This spits out:
    Code:
    <activity>
      <description><![CDATA[DESC4]]></description>
    </activity>
    What I'm after is:
    Code:
    <module>
    	<modName><![CDATA[MODULE2]]></modName>
    	<activityList>
    		<activity>
    			<description><![CDATA[DESC3]]></descriptionAW>
    		</activity>
    		<activity>
    			<description><![CDATA[DESC4]]></descriptionAW>
    		</activity>
    	</activityList>
    </module>
    Or ultimately just "MODULE2"

  2. #2
    Got it!!!

    Code:
    data.module.(descendants("description").text().contains("DESC4")).modName

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center