1. generate an XML file.
In ADO, use recordset. the Save method can save the query content to the specified XML file. In this way, the generated file contains a lot of data table attributes, that is, <s: schema> </s: schema> node content. What we need is the content of the <RS: DATA> </RS: DATA> node. The structure is roughly as follows: Data. xml
<XML...>
<S: schema>
...
</S: schema>
<RS: DATA>
<Z: Row positionid = '000000' positionname = 'fdsafsd' companyid = '1' pmid = '000000'/>
<Z: Row positionid = '000000' positionname = '. Net developer' companyid = '2' pmid = '000000'/>
</RS: DATA>
<Z: Row/> is a data row. The next step is to display this part.
2. loadxml file.
<Script language = JavaScript>
VaR xmldoc = new activexobject ("Microsoft. xmldom ");
VaR currnode;
Xmldoc. async = false;
Xmldoc. Load ("data. xml ");
If (xmldoc. parseerror. errorcode! = 0) {// if an error occurs while opening the file
VaR myerr = xmldoc. parseerror;
Document. Write ("You have error" + myerr. Reason );
}
Else
{
Document. Write ("<HR size = 1> ");
Xmldoc. setproperty ("selectionlanguage", "XPath ");
Currnode = xmldoc.doc umentelement. childnodes [1]; // obtain the <RS: DATA> section
Alert (currnode. childnodes [0]. attributes [0]. Value); // Test Result
For (I = 0; I <currnode. childnodes. length; I ++) // traverse each 'data row'
{
For (j = 0; j <currnode. childnodes [I]. Attributes. length; j ++) // traverse each attribute of a row
{
Document. write (currnode. childnodes [I]. attributes [J]. name + ":" + currnode. childnodes [I]. attributes [J]. value + "<br> ");
}
Document. Write ("<HR size = 1> ");
}
}
</SCRIPT>