rekam Posted October 23, 2003 Posted October 23, 2003 Hello ! I have a XmlNodeList, which contains some nodes. I would like to "AppendChild" this nodeList to my xml file. But the method AppendChild support only XmlNode. Is there a way to simply take th nodeList and write it into a file ? Thanks! Quote
rekam Posted October 23, 2003 Author Posted October 23, 2003 I tried something like that : Dim nodeList as xmlNodeList Dim fileToChange as new XmlDocument() fileToChange.Load("file1.xml") nodeList = fileToChange.selectNodes("rootFloor/floor1/floor2") Dim i as integer For i = 0 to nodeList.Count - 1 aNodeWhichHasBeenDeclaredBefore.AppendChild(nodeList.item(i)) next This doesn't work because : "The node to be inserted is from a different document context" I'm not sure, because the "aNodeWhichHasBeenDeclaredBefore" come from a XmlDocument() file, just like fileToChange...So, I don't know... Quote
*Experts* Nerseus Posted October 23, 2003 *Experts* Posted October 23, 2003 If it's not from the same XmlDocument object then you'll get that error (I think). Have you tried to clone the node and add it, or maybe use the text of the node and insert that? I'm just throwing out some ideas, I haven't tried to append using the DOM in quite some time. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
rekam Posted October 24, 2003 Author Posted October 24, 2003 Ok, I found a way to manipulate this. Instead of cloning the nodes, I do a selection and import it to my 1st file. file1stFile = New XmlDocument() ... ... ... fileParam = New XmlDocument() fileParam.Load(Environment.CurrentDirectory & "\defaut\" & Me.cbChoixParam.SelectedItem) parameters = fileParam.SelectSingleNode("defaultValues/paramDefault") param = file1stFile .ImportNode(parameters, True) game.AppendChild(param) Paramters, param and game are XmlElement. The "fileParam" is the file where I have node to put in my 1st file. The "game" element belong to the first file. With ImportNode, there's no problem of compatibility, but I didn't resolve the problem of the XmlNodeList. Well, it works that way, so it's c:D :D l Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.