ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 307,220 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,637 people online right now. Registration is fast and FREE... Join Now!




Removing a node and its child in xml with asp and vbscript

 

Removing a node and its child in xml with asp and vbscript

rkmalbz

17 Aug, 2009 - 09:35 AM
Post #1

New D.I.C Head
*

Joined: 10 Aug, 2009
Posts: 26


My Contributions
hello guys im wondering how to be able to remove a node and its child node in xml using asp and vbscript.

Code below is for adding data to the xml.

sports.xml
CODE

<?xml version="1.0"?>
<sports>
    <game>
        <id>01</id>
        <title>Cricket</title>
        <teams>5</teams>
    </game>
    <game>
        <id>02</id>
        <title>Cricket</title>
        <teams>5</teams>
    </game>
</sports>


add.asp
CODE

%  id=request.form("id")
    title=request.form("title")
    teams=request.form("teams")


set xmlDoc=Server.CreateObject("MICROSOFT.FreeThreadedXMLDOM")
            xmlDoc.async=false
            xmlDoc.load(Server.MapPath("g.xml"))
    
            set nodeList = xmlDoc.getElementsByTagName("sports")
            
            if(nodeList.length > 0) then
                set parentNode=nodeList(0)
                set gameNode=xmlDoc.createElement("game")
                set idNode=xmlDoc.createElement("id")
                set titleNode=xmlDoc.createElement("title")
                set teamsNode=xmlDoc.createElement("teams")
                
            end if
            
            
                idNode.text=id
                titleNode.text=title
                teamsNode.text=teams
                parentNode.appendChild(gameNode)
                gameNode.appendChild(idNode)
                  gameNode.appendChild(titleNode)
                gameNode.appendChild(teamsNode)
            
                xmlDoc.save(Server.MapPath("g.xml"))
            
        
    %>


My question is how would i do the delete? Hoping for someone to offer some explanation about deleting.

User is offlineProfile CardPM
+Quote Post


rkmalbz

RE: Removing A Node And Its Child In Xml With Asp And Vbscript

18 Aug, 2009 - 07:10 PM
Post #2

New D.I.C Head
*

Joined: 10 Aug, 2009
Posts: 26


My Contributions
ok..forget about the delete..base on my code below..how do i do like isset() in php to asp..my code below execute automatically when it is loaded. How do i put like isset() so that it will wait for a users input while it load.
CODE

<%@ language="VBScript" %>
<%    id=request.form("id")
    lastname=request.form("lastname")
    firstname=request.form("firstname")


set sampleDoc=Server.Createobject("MICROSOFT.FreeThreadedXMLDOM")
    sampleDoc.async=false
    sampleDoc.load(Server.MapPath("sample.xml"))

    set nodeList = sampleDoc.getElementsByTagName("studentsinfo")

    if(nodeList.length > 0) then
        set parentNode=nodeList(0)
        set studentNode=sampleDoc.createElement("student")
        set idNode=sampleDoc.createElement("id")
        set LNode=sampleDoc.createElement("lastname")
        set FNode=sampleDoc.createElement("firstname")

    end if


        idNode.text=id
        LNode.text=lastname
        FNode.text=firstname
        parentNode.appendChild(studentNode)
        studentNode.appendChild(idNode)
        studentNode.appendChild(LNode)
        studentNode.appendChild(FNode)

        sampleDoc.save(Server.MapPath("sample.xml"))

%>

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:24PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month