Can somebody please explain to me what's going on here?
I can load an external .xml sheet no problem. I can trace the entire content of that .xml sheet no problem. I CAN'T seem to directly access the tags. When I try to trace them, I get nothing.
Here's the code (called from another script. I pass the URL location of the .xml file)
Here is the xml fileCode:public function init(target:String) { myLoader.load(new URLRequest(target)); myLoader.dataFormat = URLLoaderDataFormat.TEXT; myLoader.addEventListener(Event.COMPLETE, processXML); } public function processXML(e:Event):void { var xml:XMLList = XML(myLoader.data); trace(xml.responseDeclaration); //traces nothing trace(xml) //traces all xml code }
The only thing I can get to work at this point is to access the tags via:Code:<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="UTF-8" ?> <assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 http://www.imsglobal.org/xsd/imsqti_v2p1.xsd" identifier="PDC_PM101_C1_FE1_Q1" title="Question" timeDependent="false" adaptive="false"> <responseDeclaration identifier="Q1" cardinality="single"> <correctResponse> <value>A</value> </correctResponse> <mapping defaultValue="0"> <mapEntry mapKey="A" mappedValue="10" /> <mapEntry mapKey="B" mappedValue="0" /> <mapEntry mapKey="C" mappedValue="0" /> <mapEntry mapKey="D" mappedValue="0" /> </mapping> </responseDeclaration> <itemBody> <p>Which statement is TRUE about the Statement of Work (SOW)?</p> <choiceInteraction responseIdentifier="Q1" maxChoices="1" shuffle="true"> <simpleChoice identifier="A">When the customer and the project team belong to the same business, the SOW is the only project agreement required.</simpleChoice> <simpleChoice identifier="B">When the customer and the project team belong to the same business, no SOW is required.</simpleChoice> <simpleChoice identifier="C">The SOW is a legal contract.</simpleChoice> <simpleChoice identifier="D">A SOW is sufficient when the project team and the customer are different legal entities.</simpleChoice> </choiceInteraction> </itemBody> <!--<responseProcessing template="explanationTemplate.xml" />--> <!--<modalFeedback outcomeIdentifier="EXPLANATION" identifier="completed" showHide="show"> <p>The project charter authorizes a project and includes the initial project requirements.</p> <p>Reference: <i>A Guide to the Project Management Body of Knowledge (PMBOK® Guide)</i> Chapter 4, Section 4.1.</p> </modalFeedback> --> </assessmentItem>
trace(xml.children()[0].localName()) //traces responseDeclaration
trace(xml.children().length() //traces 2
I do NOT want to have to resort to recursive functions as a "work around".


Reply With Quote
