易截截图软件、单文件、免安装、纯绿色、仅160KB

请教js解析xml问题 - Web 开发 / JavaScript

xml文档:books.xml

<bookstore>
<book category="children">
<title lang="en">sky</title>
<author></author>
</book>
</bookstore>

js文档:
<html>
<head>
<script type="text/javascript" src="/example/xdom/loadxmldoc.js"></script>
</head>
<body>

<script type="text/javascript">
xmlDoc=loadXMLDoc("/example/xdom/books.xml");

x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
txt=x.nodeValue;
document.write("title="+txt);

y=xmlDoc.getElementsByTagName("author")[0].childNodes[0];
txt1=y.nodeValue;
document.write("author="+txt1);
</script>
</body>
</html>

遍历节点的时候可以得到 title=sky
为何得不到author= 
是不是因为author节点的值为空,我想得到author= 如何编写程序呢?


附:
loadxmldoc.js文档:

function loadXMLDoc(dname) 
{
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
  {
  xmlDoc=document.implementation.createDocument("","",null);
  }
  cat


相关问答:

vb读取xml - VB / 基础类

现在有个xml文件是<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xm ......

Document解析xml遇到的问题~~ - 移动平台 / Android

XML文件内容:
- <ResList>
  <page>0</page> 
- <resItem>
  <resName>WWW</resName> 
  </resItem>
- <resItem>
&nb ......

SQL server分解XML - MS-SQL Server / 应用实例

下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......

XML压缩传输 - PowerBuilder / Web 应用

功能说明:Java servlet 把XML数据压缩后发送到PB用户端,PB收到数据后解压出来.
传输要经过Base64编码.
问题是:能收到数据但是解压不出来.想请教大家或者有什么好的办法?
PB可以用"zlibwapi.DLL" 解压
......

关于xml - MS-SQL Server / 基础类

sqlserver中的 xml有什么用啊
好像老看到什么xml
但我怎么没用到啊?
xml应该是用在web中的吧
我怎么没碰到过
什么样的情况应该使用他
你把web中的xml保存在数据库中 就可以用

呵呵 只是方便生成xml文件吧, ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号