rekam Posted October 28, 2003 Posted October 28, 2003 Hello! I need some help to use the method ReplaceChild. What I know is the structure of it. domDoc.ReplaceChild( newChild, oldChild ) The problem I have is that the new child is not from the same dom document as the old child. The thing is, I don't understand why the two of them must be from the same file. It's not very logical...:confused: I mean, I have a node in a document. If I want to replace it, the new node will be *in any case* a node that is not in the file, I think... Well, I'm a bit confused about that. But I abolutely need this method, and I can't have the two nodes coming from the same document, sob... If someone has an idea...thanks a LOT ! Quote
rekam Posted October 28, 2003 Author Posted October 28, 2003 Here's a part of my code...The error is : "The node to be removed is not a child of this node"... Dim fDom As New XmlDocument fDom.Load(Me.fileName) Dim paramDefault As XmlElement Dim oldParam As XmlNode 'This method returns a XmlElement type. It puts in paramDefault some children and some values. The fDom is passed by reference. paramDefault = Me.SetParamDefault(fDom) 'Then we select the old node from the document. Game is the root element. oldParam = fDom.SelectSingleNode("game/paramDefault") 'Here's the error... fDom.ReplaceChild(paramDefault, oldParam) fDom.Save(fichierTemp) I use the SetParamDefault method in other method and function in my class, and it works perfectely... Maybe I'm wrong, but it seems everything 's right.. Quote
*Experts* Bucky Posted October 28, 2003 *Experts* Posted October 28, 2003 I believe I see the problem. The only child node of fDom is the "game" node; thus, the "game/paramDefault" node is not a child of the fDom document, it's a child of the "game" node. You need to call the ReplaceChild of the "game" node instead of the ReplaceChild method of the main document. 'Here's the error... fDom.SelectSingleNode("game").ReplaceChild(paramDefault, oldParam) Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
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.