Title:ASP Script to Insert into XML

<%@ LANGUAGE="VBSCRIPT" %>

<%
    response.ContentType = "text/xml"
   
    ' Create an ASP XML parser object
    set xml0 = Server.CreateObject("Chilkat.Xml")

    ' Returns the XML page as a Variant
    set xml = xml0.HttpGet("http://www.xml-parser.com/companies.xml")

    ' Insert a new company
    set companyNode = xml.NewChild("company", "")
    set nameNode = companyNode.NewChild("name", "Apple Computer, Inc.")

    ' Add an attribute to this node.
    nameNode.AddAttribute "Symbol", "AAPL"

    companyNode.NewChild2 "address", "1 Infinite Loop"
    companyNode.NewChild2 "city", "Cupertino"
    companyNode.NewChild2 "state", "CA"
    companyNode.NewChild2 "zip", "95014"
    companyNode.NewChild2 "website", "http:www.apple.com"
    companyNode.NewChild2 "phone", "408-996-1010"

    response.write xml.GetXml()
%>

0 comments:

Post a Comment