這裡列出了您在使用 XML 時應該盡量避免使用的技術。
Internet Explorer - XML 資料島
它是什麼? XML 資料島是嵌入到 HTML 頁面中的 XML 資料。
為什麼要避免使用它? XML 資料島只在 Internet Explorer 瀏覽器中有效。
用什麼代替它? 您應該在 HTML 中使用 JavaScript 和 XML DOM 來解析並顯示 XML。
如需更多有關 JavaScript 和 XML DOM 的信息,請訪問我們的 XML DOM 教程。
XML 資料島實例
本範例使用 XML 文件 "cd_catalog.xml"。
把 XML 文件綁定到 HTML 文件中的一個 <xml> 標籤。 id 屬性定義資料島的標識符,而src 屬性指向XML 檔案:
實例
<html> <body> <xml id="cdcat" src="cd_catalog.xml"></xml> <table border="1" datasrc="#cdcat"> <tr> <td><span datafld="ARTIST"></span></td> <td><span datafld="TITLE"></span></td> </tr> </table> </body> </html>
運行實例»
#點擊"運行實例" 按鈕查看線上實例
<table> 標籤的datasrc 屬性把HTML 表格綁定到XML 資料島。
<span> 標籤允許 datafld 屬性引用要顯示的 XML 元素。在這個實例中,要引用的是 "ARTIST" 和 "TITLE"。當讀取 XML 時,會為每個 <CD> 元素建立對應的表格行。Internet Explorer - 行為
它是什麼?
Internet Explorer 5 引進了行為。行為是透過使用 CSS 樣式向 XML (或 HTML )元素添加行為的一種方法。
為什麼要避免使用它?
只有 Internet Explorer 支援 behavior 屬性。
使用什麼來代替它?
使用 JavaScript 和 XML DOM(或 HTML DOM)來取代它。實例1 - 滑鼠懸停反白
下面的HTML 檔案中的<style> 元素為<h1> 元素定義了一個行為:
<html><head><style type="text/css">
h1 { behavior: url(behave.htc) }
</style><html>
<head>
<style type="text/css">
h1 { behavior: url(behave.htc) }
</style>
</head>
<body>
<h1>Mouse over me!!!</h1>
</body>
</html>#########運行實例»######點擊"運行實例" 按鈕查看線上實例############實例2 - 打字機模擬
下面的HTML 檔案中的<style> 元素為id 為"typing" 的元素定義了一個行為:
#<html> ;
<head>
<style type="text/css">
#typing
{
behavior:url(typing.htc);
font-family :'courier new';
}
</style>
</head>
<body>
<span id="typing" speed=" 100">IE5 introduced DHTML behaviors.
Behaviors are a way to add DHTML functionality to HTML elements
with the ease of CSS.<br /><br />How do behaviors work<br />How do behaviors work< ;br />
By using XML we can link behaviors to any element in a web page
and manipulate that element.</p>v </span>
</body>
</html>
<head>
<style type="text/css">
#typing
{
behavior:url(typing.htc);
font-family :'courier new';
}
</style>
</head>
<body>
<span id="typing" speed=" 100">IE5 introduced DHTML behaviors.
Behaviors are a way to add DHTML functionality to HTML elements
with the ease of CSS.<br /><br />How do behaviors work<br />How do behaviors work< ;br />
By using XML we can link behaviors to any element in a web page
and manipulate that element.</p>v </span>
</body>
</html>
下面顯示的是XML 文件"typing.htc":
實例
<attach for="window" event="onload" handler="beginTyping" />
<method name="type" />
<script>
var i,text1,text2,textLength,t;
function beginTyping()
{
i=0;
text1=element.innerText;
textLength=text1.length;
element.innerText="";
text2="";
t=window.setInterval(element.id+".type()",speed);
}
function type()
{
text2=text2+text1.substring(i,i+1);
element.innerText=text2;
i=i+1;
if (i==textLength)
{
clearInterval(t);
}
}
</script>運行實例»
點擊"運行實例"按鈕查看線上實例












![PHP實戰開發極速入門: PHP快速創建[小型商業論壇]](https://img.php.cn/upload/course/000/000/035/5d27fb58823dc974.jpg)









