<html>
<head>
<script type="text/javascript">
var http;
if (window.XMLHttpRequest) { Xm = new XMLHttpRequest(); }
else { Xm = new ActiveXObject("Microsoft.XMLHTTP"); }
Xm.open("GET", "myfile.xml", false);
Xm.send();
var xmlDoc = Xm.responseXML;
var x = xmlDoc.getElementsByTagNameNS("https://dotnetheaven.com/NS", "name")[0];
function check() {
var y = x.hasAttributeNS("https://dotnetheaven.com/NS", "currency");
document.getElementById("tst").innerHTML = y;
};
function remove() {
x.removeAttributeNS("https://dotnetheaven.com/NS", "currency");
};
</script>
</head>
<body>
<button onclick="check()">
click me</button>
<button onclick="remove()">
Remove attribute</button>
<p id="tst" style="color: Blue">
click button to check name element has currency attribute exist or not</p>
</body>
</html>
|