Home All Groups Group Topic Archive Search About


Author
1 Mar 2006 5:54 PM
ljb
Does anyone have an example of ASP streaming XML? Can I set content headers
to indicate the page returns XML? Can this XML be a string or must it be
prepared with DOM? I need to create an ASP that queries Access and Oracle,
combines the data and returns it as XML.

thanks
LJB

Author
2 Mar 2006 9:30 AM
Anthony Jones
>Does anyone have an example of ASP streaming XML?

Without using a DOM

Response.ContentType = "text/xml"

Response.Write "<?xml version=""1.0"" encoding=""windows-1252"" ?>"
Response.Write "<root><item>Hello World</item></root>"



Using a DOM



Dim oXML
Set oXML = Server.CreateObject("MSXML2.DOMDocument.3.0")

oXML.LoadXML "<root />"

AddElem oXML, "item", "Hello World"

Response.CharSet = "UTF-8"
Response.ContentType = "text/xml"
oXML.Save Response

Function AddElem(roParent, rsName, rvntValue)
Set AddElem = roParent.ownerDocument.createElement(rsName)
If Not IsNull(rvntValue) AddElem.Text = CStr(rvntValue)
End Function


>Can I set content headers to indicate the page returns XML?

Response.ContentType = "text/xml"

>Can this XML be a string or must it be prepared with DOM?

It is strongly recommend you use DOM if at all possible.  Generating XML
using a string requires your code to perform appropriate character escaping.

>I need to create an ASP that queries Access and Oracle,
> combines the data and returns it as XML.

Access text fields are unicode.  For best results use a DOM.

Anthony.
Author
2 Mar 2006 4:10 PM
ljb
Very helpful!

thank you

AddThis Social Bookmark Button