topical media & game development
basic-xml-11-DOMException.htm / htm
<html>
<head>
<title>Raising a DOMException</title>
</head>
<body>
<p>Deliberately raising a DOMException by trying to add a second child element to the Document node.</p>
<script language="JScript" type="text/javascript">
try {
var strXML = "<?xml version='1.0' ?><AnyElement>Some text</AnyElement>"
var objXMLDOM = new ActiveXObject("Msxml2.DOMDocument.3.0");
objXMLDOM.loadXML(strXML);
var strXML2 = "DisallowedElement";
var newElement = objXMLDOM.createElement(strXML2);
alert("Everything is working nicely until now.");
objXMLDOM.appendChild(newElement);
}
// If there is an exception it must be in the preceding statement
// since the first alert box displayed correctly.
catch (e)
{
alert("An exception was raised.");
}
</script>
</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.