microsoft.xmldom(一) xml文档遍历js
xml:
<?xml version="1.0" encoding="utf-8" ?>
<library>
<name>首都图书馆</name>
<address>朝阳区华威桥南</address>
<books>
<book>
<id>0000</id>
</book>
<book>
<id>0001</id>
<name>Xml初学</name>
<publisher>人民出版社</publisher>
<publishdate>2010-05-0-18</publishdate>
<fee>100.54</fee>
</book>
<book>
<id>0002</id>
<name>XSD定义</name>
<author>子弟</author>
<publisher>子弟出版社</publisher>
<publishdate>2010-05-0-18</publishdate>
<fee>102.54</fee>
</book>
</books>
</library>
js:
<script type="text/javascript">
function loadXMLDoc(dname) {
var xmlDoc;
// code for IE
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
xmlDoc = do
相关文档:
代码如下:
DECLARE
@TempTable table(UserID int , UserName nvarchar(50));
insert into
@TempTable (UserID,UserName) values (1,'a')
insert into @TempTable
(UserID,UserName) values (2,'b')
select UserID,UserName
from @TempTable FOR XML PATH
运行这段脚本,将生成如下结果:
复制代码
......
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
&nb ......
2010-05-16
三、解析XML文档
l Xerces解析器、SAX类和接口
l SAX阅读器
n 首先要得到一个符合SAX org.xml.sax.XMLReader接口规范的例子,这个接口定义了解析行为并允许设置某些特征和属性。该接口替换了SAX1.0中的org.xml.sax.Parser
import org.apache.xerces.parsers.SAXParser;
import org.xml. ......