Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-04-2003, 04:49 PM   #1
boyzdynasty
Senior Member
 
boyzdynasty's Avatar
 
Join Date: Aug 2002
Location: Philly
Posts: 2,583
Default new to XML... problems parsing data

New to XML and just picked it up from the tutorial.
I'm just not getting the output I want.

here is the AS code in flash
ActionScript Code:
data_xml = new XML(); data_xml.ignoreWhite = true; data_xml.onLoad = function(sucess) {         if (sucess) {                 processDATA(data_xml);         } }; data_xml.load('xmlResource.xml'); function processDATA(xml_data) {         for (a in xml_data.firstChild.childNodes) {                 for (b in xml_data.firstChild.childNodes[a].firstChild.childNodes) {                     trace("a=" + a +" b=" + b + " " + xml_data.firstChild.childNodes[a].firstChild.childNodes[b]);                 }         } }
XML file
Code:
<INFO>
    <TUTORS>
	<TUTOR major="CIS" year="Senior">Ge, Yan</TUTOR>
	<TUTOR major="CIS" year="Senior">Oguntunde, Olusola</TUTOR>
    </TUTORS>
    <RESOURCES>
    	<RESOURCE><a href="http://www.temple.edu/counseling/services.html#casa" target="_blank"><font color="#FF0000">CASA</font></a></RESOURCE>
    	<RESOURCE><a href="http://www.temple.edu/counseling/services.html#cert" target="_blank"><font color="#FF0000">CERT</font></a></RESOURCE>
    	<RESOURCE><a href="http://www.temple.edu/disability/" target="_blank"><font color="#FF0000">Disability Services</font></a></RESOURCE>
    	<RESOURCE><a href="http://www.temple.edu/counseling/services.html#sace" target="_blank"><font color="#FF0000">SACE</font></a></RESOURCE>
    </RESOURCES>
</INFO>
I hoped to access the value and display it as...

a=1 b=0 <a href="http://www.temple.edu/counseling/services.html#casa" target="_blank"><font color="#FF0000">CASA</font></a>

a=1 b=3 <a href="http://www.temple.edu/counseling/services.html#sace" target="_blank"><font color="#FF0000">SACE</font></a>

a=1 b=2 <a href="http://www.temple.edu/disability/" target="_blank"><font color="#FF0000">Disability Services</font></a>

a=1 b=1 <a href="http://www.temple.edu/counseling/services.html#cert" target="_blank"><font color="#FF0000">CERT</font></a>

a=0 b=1 Oguntunde, Olusola

a=0 b=0 Ge, Yan

Any ideas as to why my output is...

// From the TRACE...
a=1 b=0 <a href="http://www.temple.edu/counseling/services.html#casa" target="_blank"><font color="#FF0000">CASA</font></a>
a=0 b=0 Ge, Yan
__________________
I need a new signature!

Last edited by boyzdynasty; 09-04-2003 at 05:44 PM.
boyzdynasty is offline   Reply With Quote
Old 09-04-2003, 05:43 PM   #2
boyzdynasty
Senior Member
 
boyzdynasty's Avatar
 
Join Date: Aug 2002
Location: Philly
Posts: 2,583
Default Re: new to XML... problems parsing data

Ok...got it now...took 4ever!!

ActionScript Code:
data_xml = new XML(); data_xml.ignoreWhite = true; data_xml.onLoad = function(sucess) {         if (sucess) {                 processBook(data_xml);         } }; data_xml.load('xmlResource.xml'); function processBook(xml_data) {         // xmlDoc_xml is now a reference to the XML         // object where our information is stored         for (a in xml_data.firstChild.childNodes) {                         for (var b=0; b < xml_data.firstChild.childNodes[a].childNodes.length; b++) {                        trace("a=" + a +" b=" + b + " " + xml_data.firstChild.childNodes[a].childNodes[b].firstChild);                 }         } }
__________________
I need a new signature!
boyzdynasty is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:39 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.