日期:2014-05-19  浏览次数:20409 次

javascrip + xsl + xml的郁闷问题,望各位帮忙,顶都有分,都开第三个贴了.
我想用javascript   +   xsl+XML无法解释XML,郁闷中。生成XML的代码如下
string   temp= " <?xml   version=\ "1.0\ "   encoding=\ "UTF-8\ "?> \n <Prices> \n ";
temp   += " <Metal   Name=\ "cu\ "   Prompt=\ "3M\ " ";
temp   += "   Price=\ "32\ "   Lots=\ "3\ "   Depth=\ "1\ "   Vol=\ "3\ "   > \n ";
temp   += " <Bids> \n ";
temp   += " <Bid   Name=\ "CU\ "   Broker_Code=\ "CA\ "   Prompt=\ "2007-06-23\ "   Broker_Prompt=\ "3M\ "     Price=\ "1\ "   Lots=\ "1\ "   Depth=\ "1\ "     brokerno=\ "3\ "/> ";
temp   += " </Bids> \n <Offers> \n ";
temp   += " <Offer   Name=\ "CU\ "   Broker_Code=\ "CA\ "   Prompt=\ "2007-06-23\ "   Broker_Prompt=\ "3M\ "     Price=\ "3\ "   Lots=\ "1\ "   Depth=\ "2\ "   brokerno=\ "3\ "/> ";
temp   += " </Offers> \n </Metal> \n ";
temp+=   " </Prices> \n ";
Response.AddHeader( "ContentType ",   "text/xml ");
Response.Write(temp);
Response.End();

解释XML的JAVASCRIPT程序如下。
      function   aa()
{  
XmlHttp       =       new       ActiveXObject( "Microsoft.XMLHTTP ");      
XmlHttp.open( "POST ", "online_select.aspx ",false,null,null);
  XmlHttp.send();
var   xmldoc,   xsldoc;
xmldoc   =   new   ActiveXObject( "Msxml2.DOMDocument ");
xsldoc   =   new   ActiveXObject( "Msxml2.DOMDocument ");
xmldoc.async   =   false;
xsldoc.async   =   false;
xmldoc.load(XmlHttp.responseXML);
xsldoc.load( "select_price_main.xsl ");
bodyStr   =   xmldoc.transformNode(xsldoc)  
trade_veiw.innerHTML=bodyStr;
alert(bodyStr);
}
超级郁闷没法显示。如果将生成XML的ASP。NET换成XML就正常显示。郁闷。XML文件如下。
<?xml   version= '1.0 '   encoding= 'UTF-8 '?>
<?xml-stylesheet   type= 'text/xsl '   href= 'select_price_main.xsl '   ?>
<Prices>
<Metal   Name= 'CU '   Prompt= '3M '     Price= '6700 '   Lots= '3 '   Depth= '1 '   Vol= '3 '>
<Bids>
<Bid   Name= 'CU '   Broker_Code= 'CA '   Prompt= '2007-06-23 '   Broker_Prompt= '3M '     Price= '1 '   Lots= '1 '   Depth= '1 '     brokerno= '3 '/>
  </Bids>
<Offers>
<Offer   Name= 'CU '   Broker_Code= 'CA '   Prompt= '2007-06-23 '   Broker_Prompt= '3M '     Price= '3 '   Lots= '1 '   Depth= '2 '   brokerno= '3 '/>
  </Offers>
</Metal>
</Prices>

------解决方案--------------------
帮你ding
------解决方案--------------------
Response.Clear();
string temp= " <?xml version=\