以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  getElementById 返回null, 但是getElementsByTagName 可以工作!为何?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=38641)


--  作者:wywywywy
--  发布时间:10/8/2006 5:48:00 PM

--  getElementById 返回null, 但是getElementsByTagName 可以工作!为何?
找了一个例子,mall.*
里面有:
function retrieveData(evt){
 window.getURL("stores.xml",retrieveDataCallBack);
 return "";
 }

function retrieveDataCallBack(resultObject){
 if (resultObject.success){
  mallData = window.parseXML(resultObject.content);
   alert( printNode(mallData .getElementById("test1")));
  }
 else {
  alert("stores.xml could not be found");
  }
 return "";
 }

我在stores.xml里增加了< test1  id="test1" />.用mallData .getElementById("test1")返回null,mallData .getElementsByTagName("test1").item(0)可以得到。请问,为啥?


--  作者:wywywywy
--  发布时间:10/8/2006 6:19:00 PM

--  高手来看看!
顶一下先!
--  作者:kun331
--  发布时间:10/10/2006 4:43:00 PM

--  
http://community.csdn.net/Expert/topic/5047/5047461.xml?temp=.7265741
--  作者:wywywywy
--  发布时间:10/16/2006 6:21:00 PM

--  加了 DTD,和  <!ATTLIST outline id ID   #REQUIRED> 也不行。
郁闷!
--  作者:wywywywy
--  发布时间:10/16/2006 6:23:00 PM

--  DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE outline [
<!ELEMENT outline  (#PCDATA)>
  <!ATTLIST outline id ID   #REQUIRED>
  ]>
<outline id= "overall" >wwwww  </outline>
--  作者:wywywywy
--  发布时间:10/16/2006 8:16:00 PM

--  
用mallData .getElementById("overall")返回null,mallData .getElementsByTagName("outline").item(0)可以得到.
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
2,110.352ms