首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

xml数据岛源码,啥地方不对啊该怎么解决

2012-02-02 
xml数据岛源码,啥地方不对啊IEXMLdataisland:..xmlid xmldataisland foo bar /foo/xmlSCRIPTl

xml数据岛源码,啥地方不对啊

  IE   XML   data   island:  
..  
<xml   id= "xmldataisland ">  
  <foo> bar </foo>  
</xml>  

  <SCRIPT   language= "JavaScript ">
  Cross-browser   solution:  
var   xmlString   =   " <xml  
id= "xmldataisland "> <foo> bar </foo> </xml> ";  
var   myDocument;  

if   (document.implementation.createDocument){  
  //   Mozilla,   create   a   new   DOMParser  
  var   parser   =   new   DOMParser();  
  myDocument   =   parser.parseFromString(xmlString,   "text/xml ");  
}   else   if   (window.ActiveXObject){  
  //   Internet   Explorer,   create   a   new   XML   document   using   ActiveX  
  //   and   use   loadXML   as   a   DOM   parser.  
  myDocument   =   new   ActiveXObject( "Microsoft.XMLDOM ")  
  myDocument.async= "false ";  
  myDocument.loadXML(xmlString);  
  document.write(xmldom.transformNode(myDocument));
}  
  </SCRIPT>
ie怎么取不到 "bar "?

[解决办法]
document.write(xmldom.selectSingleNode("xml/foo"));
[解决办法]

JScript code
<SCRIPT language="JavaScript">   //Cross-browser solution: var xmlString = " <xml id=\"xmldataisland\" > <foo >bar </foo > </xml >";  var myDocument;    if (document.implementation.createDocument){   // Mozilla, create a new DOMParser   var parser = new DOMParser();   myDocument = parser.parseFromString(xmlString, "text/xml");  } else if (window.ActiveXObject){   // Internet Explorer, create a new XML document using ActiveX   // and use loadXML as a DOM parser.   myDocument = new ActiveXObject("Microsoft.XMLDOM")   myDocument.async="false";   myDocument.loadXML(xmlString);   document.write(myDocument.selectSingleNode("xml/foo").text);  }  </SCRIPT>
[解决办法]
\转码
[解决办法]
var xmlString = " <xml id=\"xmldataisland\" > <foo >bar </foo > </xml >";
Javascript中引号表示字符串的头和尾如果字符串中包含有如:双引号、反斜杠、换行符、回车符等字符时就要用到转义

热点排行