<!-- example1.htm --> <html> <head> <title>XML DSO-example1.htm</title> </head> <body bgcolor="#FFFFFF"> <xml id="xmldb"> <db> <member> <name>Premshree Pillai<name> <sex>male</sex> </member> <member> <name>Vinod</name> <sex>male</sex> </member> </db> </xml> <span datasrc="#xmldb" datafld="name"<</span> <br> <span datasrc="#xmldb" datafld="sex"></span> </body> </html> |
Name | Sex |
Premshree Pillai | male |
Vinod | male |
<!-- example2.htm --> <html> <head> <title>XML DSO-example2.htm</title> </head> <body bgcolor="#FFFFFF"> <xml id="xmldb"> <db> <member> <name>Premshree Pillai<name> <sex>male</sex> </member> <member> <name>Vinod</name> <sex>male</sex> </member> </db> </xml> <table datasrc="#xmldb" border="1"> <thead> <th>Name</th> <th>Sex</th> </thead> <tr> <td><div datafld="name"></div></td> <td><div datafld="sex"></div></td> </tr> </table> </body> </html> |
<!-- example3.xml --> <?xml version="1.0" ?> <ticker> <item> <message>JavaScript Ticker using XML DSO</message> <URL>http://someURL.com</URL> </item> </ticker> |
<!-- example3.htm --> <html> <head> <title>XML DSO-example3.htm</title> <script language="JavaScript"> function load() { var xmlDso=myXML.XMLDocument; xmlDso.load("example3.xml"); } </script> </head> <body bgcolor="#FFFFFF" onLoad="load()"> <object id="myXML" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <table datasrc="#myXML" border="1"> <thead> <th>Message</th> <th>URL</th> </thead> <tr> <td><div datafld="message"></div></td> <td><div datafld="URL"></div></td> </tr> </table> </body> </html> |
<script language="JavaScript"> var xmlDso; function load(xmlFile, objName) { eval('xmlDso='+objName+'.XMLDocument'); xmlDso.load(xmlFile); } </script> Now, to load any XML file use: load("SomeXMLFile.xml","anyXmlDsoObject"); |
<!-- example4.xml --> <?xml version="1.0" ?> <myDB> <member> <name>Premshree Pillai</name> <sex>male</sex> </member> <member> <name>Vinod</name> <sex>male</sex> </member> <member> <name>Santhosh</name> <sex>male</sex> </member> </myDB> |
<!-- example4.htm --> <html> <head> <title>XML DSO-example4.htm</title> <script language="JavaScript"> function load() { var xmlDso=myDB.XMLDocument; xmlDso.load("example4.xml"); /* Get the complete record set */ var memberSet=myDB.recordset; /* Go to next data */ memberSet.moveNext(); } </script> </head> <body bgcolor="#FFFFFF" onLoad="load()"> <object id="myDB" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <span datasrc="#myDB" datafld="name"></span> </body> </html> |
<!-- example4.xml --> <?xml version="1.0" ?> <myDB> <member> <name>Premshree Pillai</name> <sex>male</sex> </member> <member> <name>Vinod</name> <sex>male</sex> </member> <member> <name>Santhosh</name> <sex>male</sex> </member> </myDB> |
<!-- example4.htm --> <html> <head> <title>XML DSO-example4.htm</title> <script language="JavaScript"> function load() { var xmlDso=myDB.XMLDocument; xmlDso.load("example4.xml"); /* Get the complete record set */ var memberSet=myDB.recordset; /* Go to next data */ memberSet.moveNext(); } </script> </head> <body bgcolor="#FFFFFF" onLoad="load()"> <object id="myDB" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object> <span datasrc="#myDB" datafld="name"></span> </body> </html> |
<a href=" datasrc="#ticker" datafld="URL" class="tickerStyle"> <span datasrc="#ticker" datafld="message"></span> </a> |
新闻热点
疑难解答