我想用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>
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>
解决方案 »
- 如何获取我上传文件的路径
- 基础问题请教关于using return
- 求助~~~对Datatable中的数据给定一个序列(序列通过上移、下移等按钮对标题设置序列)
- Enterprise Library 2.0 连接 access2003 Web.Config配置问题
- 请教关于iTextSharp中文本上下居中
- 求高手解答?谢谢.html在线编辑器问题
- 现有十几万个用户的网站,想加一个用户组统一管理用户权限,哪位大侠能提供一个好的方法?
- 请教大家:怎样把一个页面上的HtmlInputBox或TextBox动态替换成Label
- 构建一大型电子商务网站的数据访问层(用asp.net),未来有大访问量,请有经验的同仁来聊聊
- 请问如何实现循环读取数据?
- 女友说我的简历没营养,大家给个意见,谢谢
- asp.net输出静态页面和使用URL重写两者有联系吗?
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();
XmlHttp.open("POST","online_select.aspx",false,null,null);
XmlHttp.send();
alert(XmlHttp.responseText)
看看是否是xml格式的
xmldoc = new ActiveXObject("Msxml2.DOMDocument");
xsldoc = new ActiveXObject("Msxml2.DOMDocument");
xmldoc.async = false;
xsldoc.async = false;
xmldoc.load("default.aspx")
xsldoc.load("select_price_main.xsl");bodyStr =xmldoc.transformNode(xsldoc.documentElement)
alert(bodyStr);
trade_veiw.innerHTML=bodyStr;
换成你的文件名
<?xml version="1.0" encoding="UTF-16"?><div id="divPrices" style="overflow:auto; height:100%; width:100%" class="ScrollBars" xmlns:fo="http://www.w3.org/1999/XSL/Format"></div>
xmldoc.load(XmlHttp.responseXML);
非常感谢各位的帮忙.
loadXml是xml的string内容