We help IT Professionals succeed at work.
Get Started

E4X Filtering XML

marcparillo
marcparillo asked
on
295 Views
Last Modified: 2012-05-11

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

Comment
Watch Question
Top Expert 2011
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE