topical media & game development
professional-xml-12-WorkingwithAttributes.htm / htm
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Working with Attributes</title>
<script type="text/javascript" language="javascript">
var doc;
function btnCreateAndDisplayAttribute_Click()
{
loadDocument();
createAndDisplayAttribute();
}
function loadDocument()
{
doc = new ActiveXObject("Microsoft.XMLDOM");
doc.async = false;
doc.load("Products.xml");
}
function createAndDisplayAttribute()
{
var docElement = doc.documentElement;
//Put the attribute myAtt='hello' on rootElement
docElement.setAttribute('CategoryID', '1');
//Display the value of the added attribute
result.innerText = docElement.getAttribute('CategoryID');
}
</script>
</head>
<body>
<input type="button" id="btnCreateAndDisplayAttribute" value="Create and display attribute" onclick="btnCreateAndDisplayAttribute_Click()" />
<br/><br/><br/>
<div id="result">
</div>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.