Sorry I lost track of the information available.
Your xml is fine but due to posting in the forum I cannot be sure that there
is no (non data) whitespace in the XML including no end of line characters
or tabs. That you handle in the source file or in the source server script
depending on how you do it.
Two examples below can be pasted into a blank movie on frame 1 for testing
with Control->Test movie. These are designed to simplify demonstration of
the XML parsing by Flash by avoiding an external source. Adapt to your code
by adding all the trace statements to your onLoad for debugging. Then use
what is inside the trace statements to complete your application. Example 1
should work for your current xml. Example 2 requires a modification to your
xml.
Example 1 without a wrapper node:
var testXml:String =
"<item>toaster</item><price>245.50</price><shipping>2.50</shipping>";
var my_xml:XML = new XML(testXml);
trace(my_xml.firstChild.nodeName); // output: item
trace(my_xml.firstChild.firstChild.nodeValue); // output: toaster
trace(my_xml.childNodes[0].nodeName); // output: item
trace(my_xml.childNodes[0].firstChild.nodeValue); // output:toaster
trace(my_xml.childNodes[1].nodeName); // output: price
trace(my_xml.childNodes[1].firstChild.nodeValue); // output:245.50
trace(my_xml.childNodes[2].nodeName); // output: shipping
trace(my_xml.childNodes[2].firstChild.nodeValue); // output:2.5
You might consider a wrapper node for XML. <order> ...... </order>. I simply
use <datapacket>....</datapacket>.
Example 2 with a wrapper node:
var testXml:String =
"<datapacket><item>toaster</item><price>245.50</price><shipping>2.50</shipping></datapacket>";
var my_xml:XML = new XML(testXml);
trace(my_xml.firstChild.firstChild.nodeName); // output: item
trace(my_xml.firstChild.firstChild.firstChild.nodeValue); // output: toaster
trace(my_xml.firstChild.childNodes[0].nodeName); // output: item
trace(my_xml.firstChild.childNodes[0].firstChild.nodeValue); //
output:toaster
trace(my_xml.firstChild.childNodes[1].nodeName); // output: price
trace(my_xml.firstChild.childNodes[1].firstChild.nodeValue); //
output:245.50
trace(my_xml.firstChild.childNodes[2].nodeName); // output: shipping
trace(my_xml.firstChild.childNodes[2].firstChild.nodeValue); // output:2.5
--
Lon Hosford
www.lonhosford.com May many happy bits flow your way!
[quoted text, click to view] "adamsimms" <webforumsuser@macromedia.com> wrote in message
news:dpjkdi$els$1@forums.macromedia.com...
I did post the XML file in the previous message. It is right under the code
if
you look hard. when I parse the tree to the data I want I get it in the
format
<price>245.50</price> ... this is after I chaged the parsing code and took
out
the childnode at the end. I probably am not parsing the data properly....
thanks for helping a newbie to xml format out..
adam