Link to home
Start Free TrialLog in
Avatar of petersego
petersego

asked on

How do I set else for both and

I have a situation where I am iterating a xml-string, with several id-nodes.
If one of the id-nodes equals a predefined number, the movie should show solution A, but if the predefined number does not exist as an id-node, it should show solution B.

The problem is that if I iterate the xml, both scenarios exist, if I compare IDs.
It equals an ID and it does not equals an ID.
Take a look:
var bookLength=myXML.Book;
for (var i:int; i < bookLength.length(); i++ ) {
if (myXML.Book[i].id==0684826976){
title_TF.x=30;
}
else{
title_TF.x=50;
}
}

Open in new window

The problem is that title_TF will show in both positions since both situations are correct.
But obviously I only want one of the solutions to show.


<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

ASKER CERTIFIED SOLUTION
Avatar of andreizz
andreizz
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of petersego
petersego

ASKER

Ahh, brillant, Thanks alot.
No problem, good luck!