请教js解析xml的问题 - Web 开发 / JavaScript
XML代码:317.xml
<?xml version="1.0" encoding="UTF-8"?>
<ADI>
<Objects>
<Object ElementType="Program" >
<Property Name="Name">大兵小将</Property>
<Property Name="Language">汉语</Property>
</Object>
<Objects>
<Mappings>
<Mapping ParentType="Program">
123
</Mapping>
<Mappings>
</ADI>
js代码:
<html>
<head>
<script type="text/javascript" src="loadxmldoc.js"></script>
</head>
<body>
<script type="text/javascript">
xmlDoc=loadXMLDoc("317.xml");
x=xmlDoc.getElementsByTagName("Property")[0].childNodes[0];
txt=x.nodeValue;
document.write(txt);
</script>
</body>
</html>
loadxmldoc.js导入xml文档没有问题。
解析出来为何得不到:大兵小将?
如果显示的不是中文,请问该怎么办?
alert(xmlDoc)
看看对象加载成功没有
如果显示的不是中文,请问该怎么办?
将文件另存为utf-8编码
HTML code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHi
相关问答:
<?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文件是<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xm ......
CSS code:
<allm version="(0,0)">
<Items type="associative_array">
<item type="pair">
<key ......