js解析xml问题 - Web 开发 / JavaScript
有完整的例子吗?兼容ff和ie的还有其他浏览器
http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery
JScript code:
<script type="text/javascript" >
function getSource(){
var doc = new ActiveXObject("MSXML2.DOMDocument.3.0");
doc.async = false;
doc.load("test.xml");
var items = doc.getElementsByTagName("country");
for(var i=0;i<items.length;i++){
var item = items[i];
var v = item.getAttribute("value") ;
document.write(v+"<br>");
}
}
getSource()
</script>
test.xml
XML code:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<country value="China">China</country>
<country value="Australia">Australia</country>
<country value="Canada">Canada</country>
<country value="Malaysia">Malaysia</country>
<country value="Singapore">Singapore</country>
<country value="United Kingdom">United Kingdom</country>
<country value="United States">United States</country>
</ro
相关问答:
<?xml version="1.0"?>
<root>
<status>433</status>
<msg>这个是汉字</msg>
<serialno>123</serialno>
</root>
如何用ASP读取 status值 ......
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<video>
<device deviceid="\\?\usb#vid_0c45&pid_613b#5&2d0620de& ......
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical&q ......
Private Sub Command1_Click()
Dim MyString() As String
Open "a.xml" For Binary As #1 ' 打开刚创建的文件。
ReDim MyString(LOF(1) - 1)
Put #1, , MyRecord ' 读入所有字符到变量中 ......
我现在有一个XML对象
var merxml
merxml 保存的内容 是
<root>
<a>a</a>
<b>b</b>
</root>
我现在的目的是要把 merxml 这个XML对象 完整的输出到一个文本框 tx ......