最近幾天一直在試,用一個頁面去控制多個 xml 檔案,一開始是以 .implementation.createDocument 建立物件,而後載入 xml 檔案,然後再一一解析 xml 節點,因為對這些不瞭解,所以大都數的時間都是花在找語法。總算是完成了。
自行用 code 去一個一個解析 xml 的節點太沒有效率了,在找到相關的 xsl 資料後,開始使用搭配 xsl 的方式來顯示資料,不過卻不知道要如何弄到控制頁面上去,又開始了漫長的資料搜尋。
var http_Request;
var xslStylesheet;
var xsltProcessor = new XSLTProcessor();
// load the xslt file
http_Request = new XMLHttpRequest();
http_Request.open("GET", XSL_URL, false);
http_Request.send(null);
// get the XML document and import it
xslStylesheet = http_Request.responseXML;
xsltProcessor.importStylesheet(xslStylesheet);
// load the xml file
http_Request = new XMLHttpRequest();
http_Request.open("GET", XML_URL, false);
http_Request.send(null);
var xmlSource = http_Request.responseXML;
var resultDoc = xsltProcessor.transformToDocument(xmlSource);
var xslStylesheet;
var xsltProcessor = new XSLTProcessor();
// load the xslt file
http_Request = new XMLHttpRequest();
http_Request.open("GET", XSL_URL, false);
http_Request.send(null);
// get the XML document and import it
xslStylesheet = http_Request.responseXML;
xsltProcessor.importStylesheet(xslStylesheet);
// load the xml file
http_Request = new XMLHttpRequest();
http_Request.open("GET", XML_URL, false);
http_Request.send(null);
var xmlSource = http_Request.responseXML;
var resultDoc = xsltProcessor.transformToDocument(xmlSource);
0 意見:
張貼留言