XML output in Flash
- Started
- Last post
- 12 Responses
- CX
How can I output all of my nodes into one text field? Anyone know? Sorry if this is unclear.
The ouput is currently like this:
msg = doc.firstChild.childNodes[1].att... + "" + doc.firstChild.childNodes[1].att... + ""
-->I guess I need to loop it somehow to output all nodes under the msg variable?
- anonote0
the message board will contain all which you desire
- unknown0
Hmm helpful!
- anonote0
This is for Engage's sarcasm:
docLength = doc.firstChild.childNodes.length...
for(i=0; i < docLength; i++) {
msg += doc.firstChild.childNodes
[i].attributes.name
msg += doc.firstChild.childNodes
[i].attributes.address
}
- unformatted0
why would you want to output everything? just curious.
- CX0
Thanks, anonote. That looks like good code. I want to output everything as in: I want the contents of the entire xml file outputted in 1 textfield instead of just one node at a time if thats possible.
I think the other option is to duplicate a MC with a textfield in it??
- anonote0
That code should fill the text field withh all the contet in your file. It is hard for me to say if it will work correctly withou seeing your XML structure.
- unformatted0
gotcha, i thought you meant all the nodes, as in element names, attributes names, and the values, etc.
use anonotes function, but yeah it's hard to determine if it will work right if we don't see you xml structure, because you might have elements inside elements.
- CX0
Here is the structure:
-->
Its from an old tutorial from were-here, think. Im just trying to get it to work to practice and then do my own stuff.
- robert0
1. Create a dynamic text field multilined, selectable. Give it var = output
2. insert code like this into 1st frame of movie.
XML.ignoreWhite = true;
recipeXML = new XML();
recipeXML.onLoad = function (success) {
if (success) {
output += "-If Zero the XML is valid = "+this.status+"
";
output += "-This is my XML document:
";
output += "
";
output += this.toString();
} else {
output += "YOUR code or LINK sucks";
}
}
recipeXML.load ("YourName.xml");This will output all you XML, depending on your XML formatting you might see it as all one line or branches.
Good Luck.
- CX0
Here is the Flash output from the last one from Robert:
-If Zero the XML is valid = 0-This is my XML document:
-->
Ill have to mess with it more.
_________________________
Here is the output from the one from anonote:NaNmesomewhere out thereyoui wouldnt care to knowushere
Works also but has NaN at the beginning.
____________________
Here is the output form a slightly tweaked version:_level0.msg
me
somewhere out thereyou
i wouldnt care to knowus
hereI changed the code like this:
for(i=0; i < docLength; i++) {
msg += doc.firstChild.childNodes[i].attributes.name + "" + doc.firstChild.childNodes[i].attributes.address + ""
}
-->
Works fine if it didnt say _level0.msg at the top in the output.Thanks for your help. Anything else. Sorry, obviously I suck at this.
- robert0
yeh you gotta change the last line with your XML file name...
None of your tags will display in this forum, so i didnt see what you pasted in.
I have done this many times and if you send me the XML doc I will get it working.
- CX0
Thanks all. I got it too work properly. Then I added a scrollbar component. You know how you are supposed to use an instance name for the text field instead of a var when using the scrollbar component? Now it doesnt render as HTML like it should. Anyone know how to make a textfield with an instance name render as html?