Hey again. I’m having yet another problem with XML, specifically accessing its elements with a nested loop. This is the code I have now:
var convoXml:XML = FP.getXML(xml);
var list:XMLList = convoXml.Message
var element:XML;
var i:Number = 0;
var j:Number = 0;
for each(element in list)
{
messagesArr[i] = new Message(element.@Content)
var list2:XMLList = element.Response
var element2:XML;
for each(element2 in list2)
{
messagesArr[i].AddResponse(new Response(element2.@Content, element2.@Value), j)
j++
}
i++
}
This does not seem to be setting the responses right I was gonna post this as a response to my earlier topic about XML because it already had the XML document typed out within it, but there was some formatting issues so I’ll just post the XML here again:
<?xml version="1.0" encoding="utf-8"?>
<Conversations>
<Message Content="This is a test message.">
<Response Content="This is a test response 1" Value="0" />
<Response Content="This is a test response 2." Value="1" />
<Response Content="This is a test response 3." Value="2" />
</Message>
<Message Content="This is test message 2">
<Response Content="This is the first response." Value="0" />
<Response Content="This is the second response" Value="1" />
<Response Content="This is the third response" Value="2" />
</Message>
<Message Content="This is test message 3">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
<Message Content="Test 4">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
<Message Content=" Test 5">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
<Message Content="Test 6">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
<Message Content="Test 7">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
<Message Content="Test 8">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
<Message Content="Test 9">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
<Message Content="Test 10">
<Response Content="" Value="" />
<Response Content="" Value="" />
<Response Content="" Value="" />
</Message>
</Conversations>