<html>
<head>
<script type="text/javascript">
var http;
if (window.XMLHttpRequest) { yy = new XMLHttpRequest(); }
else { yy = new ActiveXObject("Microsoft.XMLHTTP"); }
yy.open("GET", "myfile.xml", false);
yy.send();
var xmlDoc = yy.responseXML;
var x = xmlDoc.getElementsByTagNameNS("https://dotnetheaven.com/NS", "author")[0];
function check() {
var y = x.hasAttributeNS("https://dotnetheaven.com/NS", "country");
document.getElementById("tst").innerHTML = y;
};
function Add() {
var mm = xmlDoc.createAttributeNS("https://dotnetheaven.com/NS", "country");
mm.value = "India";
x.setAttributeNodeNS(mm);
};
</script>
</head>
<body>
<button onclick="check()">
check it</button>
<h1 id="tst" style="color: Blue">
click button to check country attribute exists or not</h1>
<p>
click this button to add country attribute</p>
<button onclick="Add()">
Add attribute</button>
</body>
</html>
|