Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

Make money selling software. Check this out here

Hosted clickbank mall. Check this out here




   Misc

   Amazon

   Links

    


Create an XML document with ASP

 

 

In this example we are going to create a simple XML document on the web server . The srtucture of the document will be as follows .

<?xml version="1.0" ?>
<news>
<newsitem>
<title>Beginners ASP</title>
<link>http://asp.myscripting.com</link>
<description>a whole load of interesting things</description>
</newsitem>
</news>

Anyway lets go with the code to create this example

<%@LANGUAGE = "VBScript" %>
<%
Response.Buffer = False
'ensure proper headers sent to the client
Response.ContentType = "text/xml"
%>
<?xml version="1.0"?>
<%
'these are our variables
Dim objXML , objNews
'create an instance of the DOM
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
'Create our root element using the createElement method
Set objXML.documentElement = objXML.createElement("news")
'Create the newsitem element
Set objNews = objXML.createElement("newsitem")
'now we will create all the child elements in this case
'title , link and description
objNews.appendChild objXML.createElement("title")
objNews.appendChild objXML.createElement("link")
objNews.appendChild objXML.createElement("description")
'now we add values to the child elements
objNews.childNodes(0).text = "Beginners ASP"
objNews.childNodes(1).text = "http://asp.myscripting.com"
objNews.childNodes(2).text = "a whole load of interesting things"
'add the newsitem element to the news element
objXML.documentElement.appendChild objNews.cloneNode(true)
'write the document using the xml method of the DOM
Response.Write objXML.xml
%>

Save this example as makexml.asp and load it into your browser .

 
 

 

 

 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Page load time(ASP)
list all databases(php)
Is a number odd or even(C Sharp)
reverse a string VB6 onwards(VB)
Display all files in a directory(ASP)
perform a DNS query(C Sharp)
Display all files on the C drive(Powershell)
Insert text into a file(ASP)

    




Copyright © 2003 by programmershelp.co.uk