How to use ASP to generate XML data documents

Source: Internet
Author: User
1. we must find out what is ultimately needed. what we need through asp or other dynamic programming languages is XML-format data, which is irrelevant to the file carrier where XML data is stored, it can be a real XML file, such as: http://www.dw

1. you must find out what is ultimately needed

Through asp or other dynamic programming languages, we finally need data in XML format, which is irrelevant to the file carrier where the XML data is located, it can be a real XML file, such as: http://www.dw8.cn/common/dw8.xml. Can also be for asp documents, such as: http://www.cnbruce.com/blog/rss2.asp

They are the embodiment of XML data. to achieve the dynamics of XML data, we need to use dynamic programming languages, such as ASP to generate it.

II. how to generate dynamic XML documents

If an XML file is generated, the dynamic file is in ASP format. Therefore, you must use FSO to generate an XML file, for example:

The following is a reference clip:
<%
Xmlfile = server. mappath ("test1.xml ")
Set fso = CreateObject ("Scripting. FileSystemObject ")
Set MyFile = fso. CreateTextFile (xmlfile, True)
MyFile. WriteLine (" ")
MyFile. WriteLine (" <世界> ")
MyFile. WriteLine (" <你好> Hello, world ")
MyFile. WriteLine (" ")
MyFile. Close
%>

View XML file content

For more information about FSO operations, see
Http://www.cnbruce.com/blog/showlog.aspcat_id=26&log_id=440

If the dynamic XML data file is generated, the name and value of the XML node can be controlled through procedural means in the dynamic document based on the content of MyFile. WriteLine.

3. how to use dynamic documents to generate XML data

If the XML file is not generated and XML data is output directly in the dynamic file, the file type (Response. ContentType) must be declared)

<% Response. ContentType = "text/XML" %>

For example, you can directly browse the following dynamic ASP document and display it as an XML data tree in the browser.

The following is a reference clip:
<%
With Response
. ContentType = "text/XML"
. Write (" ")
. Write (" <世界> ")
. Write (" <你好> Hello, world ")
. Write (" ")
End
%>

The advantage of the generated XML file is that the file that processes the XML data can be a static file. for example, the HTML file parses the XML through Javascript and XMLDOM, and the data is easy to retain, the Dynamic XML data on dynamic documents is not like this. However, in today's era of ubiquitous use of dynamic documents, it seems that this advantage has little impact on some applications. In addition, the XML data stream of dynamic documents is even more advantageous: more timely and dynamic.

 

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.