Solved

how do I get xml-children of specified index

Posted on 2011-02-19
1
546 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
1 Comment
 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Download slideshow or picture elements 16 437
Google Chrome - Where is "Enable Resource Tracking" 2 11,955
black magic design 1 129
flash in chrome 4 101
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 …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

809 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