The Code (cont)
Since the flash XML parser considers everything in the XML document (including carriage returns and newlines) as XML nodes, we check each one in turn to see if it has a node name of article. When we have a match, we put it's child nodes into an array called elementList, and loop over that! (A whole lot a' looping going on)
for(j=0;j<%lt%><=elementList.length;j++) {
elementTag = elementList[j];
elementType = elementTag.nodeName.toLowerCase();
if(elementType == "headline_text"){
headline_text = elementTag.firstChild.nodeValue;
} else {
if(elementType == "url"){
url = elementTag.firstChild.nodeValue;
}
}
}
We take each XML node in elementList and pass it into the XML Object elementTag. We do this mostly to simplify our code. Now we set the variable elementType to contain the node name of the current elementTag. This way we can check to see if the element we currently are looking at is one of the two we want. If you remember, we are looking for headline_text and url. If we find matches, ie:
if(elementType == "item_we_want"){
...
}
| » Level Advanced |
|
Added: 2000-12-13 Rating: 9 Votes: 705 |
| » Author |
| No information about the author has been provided |
| » Download |
| Download the files used in this tutorial. |
| Download (44 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!