How to generate XML data documents with ASP

Source: Internet
Author: User
Tags end reference version advantage

One must find out what is needed in the end

Through ASP or other dynamic programming languages, we ultimately need XML-formatted data, which has nothing to do with the file carrier of the XML data, it can be a real XML file, such as: Http://www.dw8.cn/common/dw8.xml. It can also be an ASP document, such as: http://www.cnbruce.com/blog/rss2.asp

They are the embodiment of XML data, in order to realize the dynamic of XML data, so need to use a dynamic programming language, such as ASP to implement it.

Ii. How to generate a dynamic XML document

If the XML file is generated, the dynamic document is in ASP format, so you must use the FSO for the generation of XML files, such as:

The following is a reference fragment:
<%
Xmlfile=server.mappath ("Test1.xml")
Set fso = CreateObject ("Scripting.FileSystemObject")
Set MyFile = fso. CreateTextFile (Xmlfile,true)
MyFile.WriteLine ("")
MyFile.WriteLine ("< World >")
MyFile.WriteLine ("< hello >hello,world")
MyFile.WriteLine ("")
Myfile.close
%>

View XML File Contents

For an operation on the FSO see
http://www.cnbruce.com/blog/showlog.aspcat_id=26&log_id=440

In the case of generating dynamic XML data files, it is possible to control the name and value of the XML node by means of the program in the dynamic document by the MyFile.WriteLine related content.

Iii. how to generate XML data using dynamic documents

So if you're not generating an XML file and you're outputting XML data directly on a dynamic document, you need to declare the type of file (i.e. Response.ContentType)

<%response.contenttype = "Text/xml"%>

For example, directly browse the following dynamic ASP document, in the browser next to display as XML data tree

The following is a reference fragment:
<%
With Response
. ContentType = "Text/xml"
. Write ("")
. Write ("< World >")
. Write ("< hello >hello,world")
. Write ("")
End With
%>

The advantage of the generated XML file is that documents that process the XML data can be static documents, such as HTML files that parse XML through JavaScript, XMLDOM, and also ease data retention, while dynamic XML data on dynamic documents is not. However, in today's dynamic documents everywhere in the era, it seems that this advantage for some applications is not very influential, even, dynamic document XML data flow instead more advantages: more timely, more dynamic.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.