Latest web development tutorials

Considerazioni XML

Ecco un elenco che si dovrebbe cercare di evitare l'uso di quando si utilizza la tecnologia XML.


Internet Explorer - isola di dati XML

Di cosa si tratta?isola di dati XML incorporato in dati XML pagine HTML.

Perché si dovrebbe evitare?isola di dati XML è valido solo nel browser Internet Explorer.

Che cosa lo ha sostituito?Si consiglia di utilizzare HTML, JavaScript e DOM XML per analizzare e visualizzazione XML.

Per ulteriori informazioni su JavaScript e DOM XML, visitare il nostro XML DOM Tutorial .


le istanze di dati XML isola

Questo esempio utilizza documenti XML " cd_catalog.xml ."

Il documento XML è legato al documento HTML in un tag <xml>. attributo id definisce un identificatore dell'isola dei dati, e l'attributo src in un file XML:

Esempi

Questo esempio vale solo per browser IE

<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>

Prova »

DATASRC attributo tag <table> della tabella HTML associata all'isola di dati XML.

<Span> tag permette DATAFLD attributo fa riferimento l'elemento XML da visualizzare. In questo esempio, per fare riferimento a "ARTIST" e "Titolo". Durante la lettura di XML, crea un corrispondente riga della tabella per ogni elemento <CD>.


Internet Explorer - Comportamento

Di cosa si tratta?Internet Explorer 5 ha introdotto comportamento. Il comportamento è un modo per aggiungere comportamento utilizzando gli stili CSS per gli elementi XML (o HTML).

Perché si dovrebbe evitare?Solo Internet Explorer supporta le proprietà di comportamento.

Che cosa lo ha sostituito?Utilizzando JavaScript e DOM XML (o HTML DOM) per sostituirlo.

Esempio 1 - mouse hover highlight

Il seguente file HTML <style> elemento per il <h1> elemento definisce un comportamento:

<html>
<head>
<style type="text/css">
h1 { behavior: url(behave.htc) }
</style>
</head>
<body>

<h1>Mouse over me!!!</h1>

</body>
</html>

è un documento XML "behave.htc" (Questo file contiene alcuni gestori di JavaScript e di eventi per l'elemento) illustrato di seguito:

<attach for="element" event="onmouseover" handler="hig_lite" />
<attach for="element" event="onmouseout" handler="low_lite" />

<script>
function hig_lite()
{
element.style.color='red';
}

function low_lite()
{
element.style.color='blue';
}
</script>

Prova »

Esempio 2 - Macchina da scrivere Simulazione

Il seguente file HTML <style> elemento id definisce l'azione per "tipizzazione" degli elementi:

<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 />
By using XML we can link behaviors to any element in a web page
and manipulate that element.</p>v </span>

</body>
</html>

Di seguito si riporta un documento 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>

Prova »