p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XML (http://p2p.wrox.com/forumdisplay.php?f=91)
-   -   Urgent Help:Deleting a node in xml using vb : (http://p2p.wrox.com/showthread.php?t=20816)

Milan November 4th, 2004 07:44 AM

Urgent Help:Deleting a node in xml using vb :
 
in vb
<book>
        <group> a
            <name>Group1</name>
            <bookname>
                <name>book1</name>
            </bookname>
            <bookname>
                <name>book2</name>
            </bookname>
        </group>
        <group> b
            <name>Group2</name>
            <bookname>
                <name>book3</name>
            </bookname>
            <bookname>
                <name>book4</name>
            </bookname>
        </group>
    </book>
so i needed to delete the node named group which has the text 'b'
delete full in between <group></group>
so
i used this coding in vb but
/////////////////////////////////
Set objnodelist = xmlDoc.getElementsByTagName("Group")

 For Each datenode In objnodelist
    If datenode.childNodes(0).Text = "a" Then
       root.removeChild (datenode)
     End If
 Next
////////////////////////////////
but getting an error in root.removechild where
object not support this method or propert


ChrisScott November 4th, 2004 08:12 AM

Hello Milan,

Try:
Code:

Call datenode.parentNode.removeChild(datenode)
HTH,

Chris


Milan November 4th, 2004 08:14 AM

if anybody knows the answer plz reply


Milan November 4th, 2004 08:19 AM

same error coming when i used this
datenode.parentNode.removeChild (datenode)
Error:'object dosn't support this property or method'


Milan November 4th, 2004 08:25 AM

ya its working after added 'call'
but not having any change in the node


ChrisScott November 4th, 2004 08:38 AM

Hi Milan,

xml is case sensitive, so
Code:

xmlDoc.getElementsByTagName("Group")
needs to be
Code:

xmlDoc.getElementsByTagName("group")
to return the elements you want

HTH,

Chris


Milan November 6th, 2004 03:28 AM

Hi Chris,

its working
Thanks







All times are GMT -4. The time now is 12:08 AM.

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