-
-
One easy way I've found is to load the XML children into an array. Then you can format the XML node as a text string, eg:
XMLNode ="<testnode><name>" + name + "</name></testnode>";
XMLArray[XMLArray.length] = XMLNode;
To update a node you'd do the same but by writing over the same array element with the newly formatted one.
I'm still not sure about how to get the array elements back into XML format to use XML.send. So let me know if you've done this.
So to get the XML into array I go:
tagList = new Array;
tagList = input.firstChild.childNodes; // where input is an xml node
Can I go
input.firstChild.childNodes = tagList ??
Hopefully
Awesome Z.
-
Senior Member
Have a look at the Macromedia XML docs, childNodes is an array and can be treated as such. Anything you can do to an array you can do to childNodes. However to add records you will need to use the appropriate function.
Thanks
Luke
-
Thanks dude.
Basically I have an array which has XML child loaded into each element - standard approach here.
tagList = input.firstChild.childNodes; //get tags from input XML
childList = tagList[0].childNodes; //populate array list
Then I want to add XML children to the array. However when I add a value to the array eg:
childList[index] = "<xml>vars</xml";
flash doesn't recognise the text as XML, leading me to guess that I need to create a new XML object, and use the XML methods createElement and createTextNode to do this. There are no examples in the manual on how to do this :-)
Alternatively I could try cloning another node:
node = doc1.lastChild.cloneNode(true);
doc2.appendChild(node);
However I am not sure how to update nodeValues or if this is possible.
If anyone else out there has solved this problem I'd like to hear from you In the meantime I'll be having a play
Thanx all,
Z.
-
And I lost the rest of the post
Here's one solution, although hardly elegant
node_test = hoursList[index].cloneNode(true);
nodeList = node_test.childNodes
for(z=0;z<=nodeList.length;z++) {
if(nodeList[z].nodeName=="comments"){
nodeList[z].firstChild.nodeValue = "updated value";
}
}
I'm going to try the createElement, createTextNode methods.
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|