[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how do I get xml-children of specified index

Posted on 2011-02-19
1
Medium Priority
?
571 Views
Last Modified: 2012-06-21
I want to catch a specific id-number in an xml-string and assign the corresponding values to textfields.

In the example below I want to compare a predifined id-number something like this way:
var bookLength=myXML.Book;
for (var i:int; i < bookLength.length(); i++ ) {
if (myXML.Book[i].id==0684826976){
title_TF.text=myXML.Book[i].title;
author_TF.text=myXML.Book[i].author;
}
}

Open in new window

so that the title_TF and author_TF  is populated with the title (Undaunted Courage) and author (Stephen Ambrose) of the specified id.
How exactly would I do that.  
<Books>
 <Book>
  <id>0553212419</id>
  <title>Sherlock Holmes: Complete Novels and Stories, Vol 1</title>
  <author>Sir Arthur Conan Doyle</author>
</Book>
<Book>
  <id>0743273567</id>
  <title>The Great Gatsby</title>
  <author>F. Scott Fitzgerald</author>
</Book>
<Books>
 <Book>
  <id>0684826976</id>
  <title>Undaunted Courage</title>
  <author>Stephen E. Ambrose</author>
</Book>
<Book>
  <id>0743203178</id>
  <title>Nothing Like It In the World</title>
  <author>Stephen E. Ambrose</author>
 </Book>
</Books>

Open in new window

0
Comment
Question by:petersego
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
deepanjandas earned 2000 total points
ID: 34933210
As you are using AS3.0 use the e4x parsing:
title_TF.text = myXML.Book.(id == "0684826976").title;
author_TF.text = myXML.Book.(id == "0684826976").author;

Open in new window

Warm Regards
Deepanjan Das
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question