All, Sorry in advance - this is probably a trivial question, but I'm trying to figure out how to create an XML node, and insert it into a specific location in an XML document.
It looks like the insertBefore method is what I need. However, the problem is that it only seems to work if I create the XML structure one node at a time (using createElement). For example, this works: my_xml = new XML("<BASEBALLFIELD />"); my_xml.firstChild.appendChild(my_xml.createElement("FIRSTBASE")); my_xml.firstChild.appendChild(my_xml.createElement("THIRDBASE")); my_xml.firstChild.insertBefore(my_xml.createElement("SECONDBASE"),my_xml.firstChild.firstChild.nextSibling); trace(my_xml.toString()); this produces: "<BASEBALLFIELD><FIRSTBASE /><SECONDBASE /><THIRDBASE /></BASEBALLFIELD>" However, this doesn't: var my_xml = new XML(); my_xml.parseXML("<BASEBALLFIELD><FIRSTBASE /><THIRDBASE /></BASEBALLFIELD>"); my_xml.insertBefore(my_xml.createElement("SECONDBASE"),my_xml.firstChild.firstChild.nextSibling); trace(my_xml.toString()); As far as I can tell, these two code samples are identical. The practical application - I'm loading a large document received from a webservice (In other words, I haven't created each node using createElement). I'd then like to locate a specific node deep in the hierarchy, and try to insert a new node before it. I can confirm that the node I'm using for the second parameter of insertBefore exists (using trace()), so I don't think that's the cause of the problem. Many thanks in advance for any help or insight! Cheers, Matt Stuehler _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders