flash data integration:
I have the following layout to my XML file . . .
<?xml version="1.0" encoding="UTF-8" ?>
<VoucherNumbers>
<GoodVoucher>20060820151601</GoodVoucher>
<CancelVoucher>
<CancelledVoucher>20060820091501</CancelledVoucher>
<CancelledVoucher>20060820102201</CancelledVoucher>
<CancelledVoucher>20060820105401</CancelledVoucher>
<CancelledVoucher>20060820114201</CancelledVoucher>
</CancelVoucher>
</VoucherNumbers>
I am trying to access the values in the various child nodes in the
'CancelledVoucher' field and the following code is returning the value of the
firstChild at that level (i.e. "20060820091501") . . .
function doAfterXmlDataIsLoaded(){
//read the XML data
var vnData:XMLNode = VoucherNumbers.firstChild; //nodeType = 1
var vnCancel:XMLNode = vnData.firstChild.nextSibling; //nodeType = 1
var vnCancelled:XMLNode = vnCancel.firstChild; //nodeType = 1
var vnCanVoucher:Array = vnCancelled.childNodes[0]; //nodeType = 3
trace(vnCanVoucher);
}
I know this is the same as coding . . .
var vnCanVoucher:Array =
vnData.firstChild.nextSibling.firstChild.childNodes[0]; //nodeType = 3
But I wanted to split the levels of the data drill down so I'm more sure of my
XML data structure. But what I can't do to access the values in the remaining
childNodes . . . or even better to search through these childNodes to find the
right value as compared to the value stored in another variable in the code?
I have tried the following lines of code to access the values in the child
Nodes array but with little success . . .
var vnCanVoucher:Array = vnCancelled.childNodes[1] //nodeType = 3 . . .
returns "undefined"
var vnCanVoucher:Array = vnCancelled.childNodes[0].nextSibling; //nodeType =
3 . . . returns "null"
var vnCanVoucher:Array = vnCancelled.childNodes[0].firstChild; //nodeType =
3 . . . returns "null"
var vnCanVoucher:Array = vnCancelled.childNodes[0].lastChild; //nodeType = 3
.. . . returns "null"
var vnCanVoucher:Array = vnCancelled.childNodes[0].childNodes[0]; //nodeType
= 3 . . . returns "undefined"
I can't quite understand where I'm going wrong here. I really thought
"vnCancelled.childNodes[0].nextSibling;" would work but obviously not. If
anyone can help point out where I'm going wrong that would be a great help.
Thank you!