Propriedade especificada XML DOM
❮ Objeto de Atração
Exemplo
O fragmento de código a seguir carrega " books.xml " em xmlDoc e exibe o nome e o valor do atributo category:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
var x, i, xmlDoc, txt;
xmlDoc = xml.responseXML;
txt = ""
x = xmlDoc.getElementsByTagName('book');
for (i = 0; i
< x.length; i++) {
txt +=
x.item(i).attributes[0].specified + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
Saída:
true
true
true
true
Definição e uso
A propriedade especificada retorna true se o valor do atributo estiver definido no documento e false se for um valor padrão em um DTD/Schema.
Sintaxe
attrObject.specified
❮ Objeto de Atração