Some friends' hosts do not support FSO, but they still need to generate HTML files. Isn't it a bit embarrassing?
Today's hosts that support ASP generally use Microsoft OS, and these OSs are generally win2k server and above systems, even if XML PARSER is not installed. It will also support XML parser parsing
and XMLDOM also has a .SAVE method. Through this, we can generate HTML files on hosts without FSO.
First, let me explain one thing. Pay attention to the standardization of HTML and XML codes.
HTML
<input name=t1>
This is no problem. The standard writing method should be <input name="t1">
But if it is in xml
<input name=t1> is definitely wrong because XML node attribute values are required to be within quotation marks.
Similarly <input name="t1"> is also wrong, because XML requires closed nodes, you can write
<input name="t1"></input>, but <input name="t1"></Input> is also wrong because XML is case-sensitive. For the input XML node, its TEXT value is empty, so you can Written as <input name="t1" />
This complies with the XML specification.
Another example is that <br> in HTML should be written as <br></br> or <br/> in XML.
image in html
<image src="test.gif">
In XML, you need to write <image src="test.gif" />
and special characters ", >, <, ', &, nodes are not allowed to cross, etc. That's all for now. As for the standardization of XML documents, this article is not Key points, please refer to relevant information.
How to use fso to generate an html file will not be discussed here. But if you use FSO, your original intention is to generate such an HTML file
<html>
<head>
<title>test</title>
<body>
<p><img src="test.gif">
</body>
</html>
There is less writing here</HEAD>. For HTML, the browser can tolerate it.
But to generate a document with XML specification, it must be
<html>
<head>
<title>test</title>
</head>
<body>
<p><img src="test.gif" /></p>
</body>
</html>
How to store this XML formatted document in the server?
dimxmlString
xmlString="<html>" & chr(10) & "<head>" & chr(10) & "<title>test</title>" & chr(10) & "</head>" & chr(10 ) & "<body>" & chr(10) & "<p><img src="test.gif" /></p>" & chr(10) & "</body>" & chr(10) & "</html>"
dimxmlDoc
set xmlDoc = server.createObject("Msxml2.DOMDocument")
xmlDoc.loadXml(xmlString)
xmlDoc.save(server.mappath("test.htm"))
set xmlDoc=nothing
The xmlDOM.loadXml() method is used here, which loads an XML DOCUMENT into the object.
This is also the reason why everyone should write the HTML to be generated as XML specification, because the LOADXML() method only supports text strings that comply with the XML specification.
Of course, you need to have write permissions on the directory.