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