Use xmldom on servers that do not support FSO

Source: Internet
Author: User

Using xmldom to Create HTML files some friends' hosts do not support FSO, but they need to generate HTML files. Isn't that difficult?

Currently, all hosts that support ASP generally use Microsoft OS, and these OS are generally Win2k server and above. Even if XML parser is not installed, XML Parser Parsing is also supported.

Xmldom also has a. Save method. In this way, we can generate HTML files on hosts without FSO.

First, pay attention to HTML and XML.Code.
Html
<Input name = T1>
This is okay. The standard format should be <input name = "T1">
But in XML
<Input name = T1> it must be incorrect because the node attribute value of XML must be enclosed in quotation marks.
Similarly, <input name = "T1"> is incorrect. Because XML requires closed nodes, you can write them
<Input name = "T1"> </input>, but <input name = "T1"> </input> is also incorrect because XML is case sensitive.
For the XML node input, its text value is null, so that it can be written as <input name = "T1"/>
In this way, the XML specification is met.
For example, <br> in HTML must be written as <br> </BR> or <br/>
Image in HTML
<Image src = "test.gif">
<Image src = "test.gif"/>

There are also special characters ", >,<,', &, nodes are not allowed to cross and so on. Let's talk about this too much. As for the standardization of XML documents, please refer to relevant materials.

How to Use FSO to generate an HTML file is not mentioned here. However, if FSO is used, your intention is to generate such an HTML file.

<HTML>
<Head>
<Title> test </title>
<Body>
<P>
</Body>
</Html>

</Head> is not written here. For HTML, the browser can tolerate it.
However, to generate a document with XML specifications, it must be

<HTML>
<Head>
<Title> test </title>
</Head>
<Body>
<P> </P>
</Body>
</Html>

How can I save this XML formatted document to the server?
Dim xmlstring
Xmlstring = "<HTML>" & CHR (10) & "Dim xmldoc
Set xmldoc = server. Createobject ("msxml2.domdocument ")
Xmldoc. loadxml (xmlstring)
Xmldoc. Save (server. mappath ("test.htm "))
Set xmldoc = nothing

The xmldom. loadxml () method is used to load an XML document to an object.
The reason for writing the HTML to be generated into XML specifications is that the loadxml () method only supports text strings that conform to XML specifications.

Of course, you must have the write permission on the directory.
Create an HTML file

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.