Use XMLDOM to create HTML files on servers that do not support FSO

Source: Internet
Author: User
Tags chr xml parser

Some friends of the host does not support FSO, but also generate HTML files, is it a bit embarrassing?

And today's support for ASP hosts are generally using Microsoft OS, and these OS are generally Win2K server and above system, even if not install XML parser will also support XML parser parsing

and Xmldom has a. Save method. By doing this, we can generate HTML files on the non-FSO host.

First, it's a point. Note the normalization of HTML and XML code.
Html
<input name=t1>
This is no problem, the standard wording should be <input name= "T1" >
But if it's in XML,
<input name=t1> must be wrong, because the XML node attribute value is required within quotation marks.
Similarly <input name= "T1" > is also wrong because XML requires closed nodes that you can write
<input name= "T1" ></input>, but <input name= "T1" ></Input> is also wrong because XML is case-sensitive
For input This XML node, its text value is empty, thus can be written as <input name= "T1"/>
This conforms to the XML specification.
Like HTML <br> in XML to write <br></br> or <br/>
Image in HTML
<image src= "Http://edu.cnzz.cn/NewsInfo/test.gif" >
Write <image src= "http://edu.cnzz.cn/NewsInfo/test.gif" in XML/>

There are special characters ", >,<, ',", nodes are not allowed to cross and so on, first say so much, as for the normalization of XML documents is not the focus of this article, please refer to the relevant information.

How to use the FSO to generate an HTML file this is not to say. But if you use FSO, your intention is to generate such HTML files

<title>test</title>
<body>
<p>
</body>

However, to generate a document with an XML specification, you must be

<title>test</title>
<body>
<p></p>
</body>

How do I save this XML-formatted document to the server?
Dim xmlstring
Xmlstring= "Dim xmldoc
Set xmldoc = Server.CreateObject ("Msxml2.domdocument")
Xmldoc.loadxml (xmlstring)
Xmldoc.save (Server.MapPath ("test.htm"))
Set xmldoc=nothing

This uses the XMLDOM.loadXML () method, which loads an XML document into an object.
This is why you want to write the HTML that you generate for the XML specification, because the Loadxml () method only supports text strings that conform to XML specifications

Of course you need to have write access to the directory



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.