Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2004, 11:37 AM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with documentElement.removeChild

Hi,
I´ve used removechild before when removing a node, like this:

Set objXML = Server.CreateObject("MSXML2.DOMDocument.4.0")
Set oldnode = Server.CreateObject("MSXML2.DOMDocument.4.0")
objXML.async = False
objXML.Load(server.mappath("mylist.xml"))
' Find the node to be deleted
Set oldnode = objXML.documentElement.selectSingleNode("//list/task[name='" & person & "']")
' Remode the node
objXML.documentElement.removeChild(oldnode)
' Save the list
objXML.save server.mappath("mylist.xml")

...which works great when I need to remove the node "task" in this list for example:

<list>
    <task>
        <name>Mike</name>
        <todo>Buy milk</todo>
    </task>
</list>

But when I try to remove a node which is one step deeper in a list I get "msxml4.dll error '80070057' The parameter Node is not a child of this Node." errors.

How do I (in vbscript) remove the first "task" node in the list below? (not based on the list-order, but on the basis of the name (like above))?

<list>
    <mytasks>
        <task>
            <name>Mike</name>
            <todo>Buy milk</todo>
        <task>
        <task>
            <name>Bob</name>
            <todo>Do dishes</todo>
        <task>
</mytasks>
</list>

Any help very appreciated.

/Mike
 
Old January 16th, 2004, 12:40 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

removeChild needs to be called from the (immediate) parent.
Code:
Set oldnode = objXML.documentElement.selectSingleNode("//list/task[name='" & person & "']")
oldnode.parentNode.removeChild(oldnode)
'save etc.
Joe (MVP - xml)
 
Old January 16th, 2004, 02:12 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, this is where I start banging my head on the table...

You might think that removeCHILD would give me a hint, but nooo... :)

Thanks a lot for helping me out. I wont tell you how much time I´ve put in trying different solutions to this earlier today, because... well, it would be embarrasing, hehe.

Thx.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Err,This document already has DocumentElement node ismailc XSLT 5 December 24th, 2007 12:40 PM
removeChild help John123 RSS and Atom 1 November 19th, 2007 12:56 PM
document.DocumentElement.RemoveChild Error jrbancroft C# 2005 2 August 7th, 2006 10:36 PM
multiple documentElement (html) objects in one doc hussainm HTML Code Clinic 2 July 14th, 2006 02:40 PM
javascript: window.open & document.documentElement rockon Javascript 2 February 3rd, 2005 04:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.