1
我試圖在通過AJAX拉動的HTML頁面上顯示我的XML和XSL。我已經將XML拉入HTML頁面,但無論我做什麼,XSL似乎都不會顯示。通過AJAX顯示XML和XSL
這裏是我的XML代碼:
<tv_guide>
<channel>
<channel_id> 1 </channel_id>
<program> <!--beginning of channel1-->
<title>News</title>
<time>HELP</time>
<duration_id>1</duration_id>
<description>ABCD</description>
</program>
</channel>
這裏是我的XSL代碼:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html'/>
<xsl:template match="/">
<xsl:for-each select="program">
<td>
<xsl:attribute name="id">
<xsl:value-of select="duration_id"/> </xsl:attribute>
<xsl:attribute name="colspan">
<xsl:value-of select="duration"/>
</xsl:attribute>
<xsl:value-of select="name"/> </td>
</xsl:for-each >
</tr>
</xsl:template>
</xsl:stylesheet>
這裏是我的AJAX代碼:
function loadXMLDocWed()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState===4 && xmlhttp.status===200)
{
document.getElementById("tabs-3").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","URL",true);
xmlhttp.send();
}
,你認爲可以幫助任何建議將不勝感激,因爲我一直堅持這一段時間了。
看起來您錯過了xml文件上的
如何將XSLT應用於XML文檔?您的XML文檔是否包含頂部的<?xml-stylesheet指令? – 2014-12-02 17:57:22
回答
您遇到了xslt腳本的問題。 你嘗試,如果你想獲得一個嵌套元素爲,每個這樣的
在XSLT做,程序你的情況,你有拖選項。
遞歸地「搜索」這樣的元素。
這樣的完整路徑。
你可以在這裏找到更多的參考文獻xslt。
miki。
來源
2014-12-02 15:58:58 MIkCode
感謝您的回覆!我試圖遞歸地做它,它一遍又一遍地顯示錶中的信息,它似乎也是錯誤的順序。我也嘗試了完整的路徑,這似乎並沒有起作用,只留下了表格標題。有沒有其他方法可以做到這一點?非常感謝。 – 2014-12-02 16:37:02
相關問題