Creating XML at Run-Time

In this page an XML document is generated as opposed to simply read from a file and sent to the client browser.


	Set XMLDoc = Server.CreateObject ("Microsoft.XMLDOM")
	Set weatherForecast = XMLDoc.createElement ("weatherForecast") Create the root element and attach it to the root.
	Set dateAttr = XMLDoc.createAttribute ("date")
	dateAttr.Text = "3/2/99"
	weatherForecast.attributes.setNamedItem (dateAttr)
	Set XMLDoc.documentElement = weatherForecast

	Set resort = XMLDoc.createElement ("resort") Add a resort.
	weatherForecast.appendChild (resort)
	set name = XMLDoc.createElement ("name")
	name.Text = "Meribel"
	resort.appendChild (name)

	Set temperatures = XMLDoc.createElement ("temperatures") Add the temperatures.
	resort.appendChild (temperatures)

	Set min = XMLDoc.createElement ("min") Add minimum temperature.
	min.Text = "100"
	temperatures.appendChild (min)

	Set max = XMLDoc.createElement ("max") Add maximum temperature.
	max.Text = "100"
	temperatures.appendChild (max)

	Response.Write "<?xml version=""1.0""?>"
	Response.Write generatedweatherForecast.xml