Example :Existing xml file "book.xml"
==========================
==========================
'''''Create new elements in XML File
dim xm
set xm=CreateObject("Microsoft.XMLDOM")
xm.load "e:\book.xml"
for i=1 to 3
s=inputbox("Enter the book title")
set newele=xm.CreateElement("Title")
set newtxt=xm.CreateTextNode(s)
newele.appendChild(newtxt)
set e=xm.DocumentElement
e.appendChild(newele)
set e=e.lastChild
Next
xm.save "e:\book.xml"
=============================================
''''''''''''Read data from xml file
dim xm
set xm=CreateObject("Microsoft.XMLDOM")
xm.load "e:\book.xml"
set x=xm.getelementsbytagname("Title")
For i=0 to x.length-1
set c=x(i).childnodes(0)
msgbox c.nodevalue
Next
=============================================
'''''''Read data from existing file and update with new values
Dim xm
Set xm=CreateObject("Microsoft.XMLDOM")
xm.load "e:\book.xml"
set x=xm.getelementsbytagname("Title")
For i=0 to x.length-1
set c=x(i).childnodes(0)
t=inputbox("Enter title")
c.nodevalue=t
Next
xm.save "e:\book.xml"
===========================================
==========================
==========================
'''''Create new elements in XML File
dim xm
set xm=CreateObject("Microsoft.XMLDOM")
xm.load "e:\book.xml"
for i=1 to 3
s=inputbox("Enter the book title")
set newele=xm.CreateElement("Title")
set newtxt=xm.CreateTextNode(s)
newele.appendChild(newtxt)
set e=xm.DocumentElement
e.appendChild(newele)
set e=e.lastChild
Next
xm.save "e:\book.xml"
=============================================
''''''''''''Read data from xml file
dim xm
set xm=CreateObject("Microsoft.XMLDOM")
xm.load "e:\book.xml"
set x=xm.getelementsbytagname("Title")
For i=0 to x.length-1
set c=x(i).childnodes(0)
msgbox c.nodevalue
Next
=============================================
'''''''Read data from existing file and update with new values
Dim xm
Set xm=CreateObject("Microsoft.XMLDOM")
xm.load "e:\book.xml"
set x=xm.getelementsbytagname("Title")
For i=0 to x.length-1
set c=x(i).childnodes(0)
t=inputbox("Enter title")
c.nodevalue=t
Next
xm.save "e:\book.xml"
===========================================
Comments
Post a Comment