Solved

how do I get xml-children of specified index

Posted on 2011-02-19
1
551 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Stop Ads in Browser Google Chrome 3 547
Video sharing with user login 3 209
how do I install adobe flash player on my ipad Air? 4 46
flash in chrome 4 110
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 …
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

860 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