Avatar of marcparillo
marcparillo

asked on 

E4X Filtering XML


I'm having the hardest time trying to figure out how to extract a particular node from an XML file using E4X filtering in Flash/Actionscript.

All I know is the <truck> id and I need to get the entire <plot> parent node based on that id.

For example:

var xmlList:XMLList = xml..plot.(trucks.truck.(id==The_id_I_Want));

So, if I need the plot for the truck whose id is 26, I would get the following xml snippet:

<plot woeid="2347584" location="Missouri">
  <latitude>38.2588940</latitude>
  <longitude>-92.4365880</longitude>
  <trucks>
    <truck>
      <id>26</id>
      <title><![CDATA[Main Truck]]></title>
      <operators>
        <permanent><![CDATA[JK Smith]]></permanent>
      </operators>
    </truck>
  </trucks>
</plot>

Thanks,
marc
<?xml version='1.0' encoding='utf-8'?>
<root>
<header><source>trucks</source>
</header>
<plotList>
<plot woeid="2512025" location="Vicksburg">
  <latitude>32.3500400</latitude>
  <longitude>-90.8815540</longitude>
  <trucks>
    <truck>
      <id>23</id>
      <title><![CDATA[Blizzard]]></title>
      <operators>
        <current><![CDATA[Mike Smith]]></current>
      </operators>
    </truck>
  </trucks>
</plot>
<plot woeid="2347584" location="Missouri">
  <latitude>38.2588940</latitude>
  <longitude>-92.4365880</longitude>
  <trucks>
    <truck>
      <id>26</id>
      <title><![CDATA[Main Truck]]></title>
      <operators>
        <permanent><![CDATA[JK Smith]]></permanent>
      </operators>
    </truck>
  </trucks>
</plot>
<plot woeid="2359991" location="Baton Rouge">
  <latitude>30.4433350</latitude>
  <longitude>-91.1869940</longitude>
  <trucks>
    <truck>
      <id>10</id>
      <title><![CDATA[Cowboy]]></title>
      <operators>
        <current><![CDATA[Mark Smith]]></current>
        <current><![CDATA[Mike Smith]]></current>
      </operators>
    </truck>
  </trucks>
</plot>
</plotList>

Open in new window

Adobe FlashXML

Avatar of undefined
Last Comment
dgofman
Avatar of dgofman
dgofman
Flag of United States of America image

Did you close </root> in your file?

<root>
	<header>
		<source>trucks</source>
	</header>
	<plotList>
		<plot woeid="2512025" location="Vicksburg">
		  <latitude>32.3500400</latitude>
		  <longitude>-90.8815540</longitude>
		  <trucks>
			<truck>
			  <id>23</id>
			  <title><![CDATA[Blizzard]]></title>
			  <operators>
				<current><![CDATA[Mike Smith]]></current>
			  </operators>
			</truck>
		  </trucks>
		</plot>
		<plot woeid="2347584" location="Missouri">
		  <latitude>38.2588940</latitude>
		  <longitude>-92.4365880</longitude>
		  <trucks>
			<truck>
			  <id>26</id>
			  <title><![CDATA[Main Truck]]></title>
			  <operators>
				<permanent><![CDATA[JK Smith]]></permanent>
			  </operators>
			</truck>
		  </trucks>
		</plot>
		<plot woeid="2359991" location="Baton Rouge">
		  <latitude>30.4433350</latitude>
		  <longitude>-91.1869940</longitude>
		  <trucks>
			<truck>
			  <id>10</id>
			  <title><![CDATA[Cowboy]]></title>
			  <operators>
				<current><![CDATA[Mark Smith]]></current>
				<current><![CDATA[Mike Smith]]></current>
			  </operators>
			</truck>
		  </trucks>
		</plot>
	</plotList>
</root>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Adobe Flash
Adobe Flash

Adobe Flash (formerly Macromedia Flash) is a cross-platform multimedia and software platform used to embed animations, video, and interactive applications into web pages and desktop and mobile applications and games. Flash displays text, vector and raster graphics to provide animations, video games and applications. It allows streaming of audio and video, and can capture mouse, keyboard, microphone and camera input. The ActionScript programming language allows creation of interactive animations, video games, web applications, desktop applications and mobile applications.

29K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo