Copy link to clipboard
Copied
problem with xml forming wrong the first example works most the time but often it puts it inside it self, example below in blue. my second way happens all the time where my document title gets put into the xml
XMLdoc.doc.x.setChildren(new XMLList());
XMLdoc.doc.y.setChildren(new XMLList());
for ( r = 0; r < mytextArray.length; r++){
XMLdoc.doc.x.appendChild(
<mystuff>{mytextArray
}
<x>
<mystuff>
<mystuff>.zzzzzzzzzzzzz</mystuff>
</mystuff>
<mystuff>.aaaaaaaaaaaaaaa</mystuff>
</x>
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
XMLdoc.doc.x.setChildren(new XMLList());
XMLdoc.doc.y.setChildren(new XMLList());
for ( r = 0; r < mytextArray.length; r++){
XMLdoc.doc.x.mystuff
}
<x>
<mystuff xmlns="codesnipp1_8_fla:MainTimeline">.zzzzzzzzzzzzz :Number = new</mystuff>
<mystuff xmlns="codesnipp1_8_fla:MainTimeline">.aaaaaaaaaaa :Number = new</mystuff>
</x>
1 Correct answer
olinh26627966 wrote
...but I could switch it all to xml and skip the arrays altogether...
For the love of god, no. The entire purpose of XML is as a generic data interchange format. It should never, ever be used as a working data structure.
Copy link to clipboard
Copied
use the trace function to debug. eg:
for ( r = 0; r < mytextArray.length; r++){
XMLdoc.doc.x.appendChild(
<mystuff>{mytextArray
trace(r,":",{mytextArray
}
Copy link to clipboard
Copied
I see it is in the Array so this is where I push it in maybe here
myxmlload2()
mytextArray.length = 0
colorArray.length = 0
for ( i = 0; i < XMLdoc.doc.x.children().length(); i++){
//var st1:init = XMLdoc.doc.y.mystuff
mytextArray.push(XMLdoc.doc.x.mystuff)
}
Copy link to clipboard
Copied
your code looks like a convoluted mess but if it works for you, that's great.
Copy link to clipboard
Copied
no it doesn't work
Copy link to clipboard
Copied
at the most basic level (ie, without trying to fix the approach you've already started), what are you trying to do?
Copy link to clipboard
Copied
I am trying to make it so xml can push into an Array and an Array can push back into the xml. I am doing this because I aleady have a bunch of code with Arrays, but I could switch it all to xml and skip the arrays altogether and I probably could get it to work but I figured it would be easy to push the Array into the XML and vice versa. I need the XML for saving purposes.
also what type of variable represents a singular xml object if I don't want it to be a string
maybe if I push the variable and not the xml chain it might not get the tags too. Just a thought
Copy link to clipboard
Copied
what are you using an array for?
what are you using xml for?
Copy link to clipboard
Copied
olinh26627966 wrote
...but I could switch it all to xml and skip the arrays altogether...
For the love of god, no. The entire purpose of XML is as a generic data interchange format. It should never, ever be used as a working data structure.
Copy link to clipboard
Copied
I got it. I was wrong about not having a string variable. The error I was having the first time I tried must of been unrelated to my string variable. So the solution was definitely putting the XML into variable form first and not putting XML directly into the Array. I don't know why it would be this way. Sloppy code maybe, I don't know, or maybe its just the way it should be.

