Hi,
I have a DOMSelection and I need to cycle through it and remove some nodes. The resulting DOMSelection will be used somewhere else. How can I achieve this?
I have tried to use the .removeChild method. This DO remove the node from the main XML document, but the original DOMSelection stays with the childnode in it.
This is the procedure that I use right now.
This procedure does nothing more than adjusting the amount of childs a given Node should have.
Another problem I have is that the linePrivate Sub SizeXmlNode(ActXpath As String, NrOfChilds As Long) Dim NodeList As MSXML2.IXMLDOMSelection Dim tNode As MSXML2.IXMLDOMNode 'glbXmlDoc is a xml Document (MSXML2.DOMDocument60) Set NodeList = glbXmlDoc.SelectNodes(ActXpath) 'If the xmlNode is too big, then trim the xml If NodeList.Length > NrOfChilds Then Do NodeList.Item(0).ParentNode.RemoveChild NodeList.Item(0) Loop Until glbXmlDoc.SelectNodes(ActXpath).Length = NrOfChilds End If End Sub 'will work only one time. After the second pass, it pops a "Object variable or With block variable not set"NodeList.Item(0).ParentNode.RemoveChild NodeList.Item(0)
Every help is very appreciated. Thanks!
Last edited by Wizz; 05-03-2011 at 09:12 AM. Reason: Adding more info
Try putting the Set NodeList inside the loop as well.
Also, your If ... Loop Until structure tells me that a While loop is more suitable.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks