blob: 58cae4db84a18a0cd3ad62ad4da12542e9b3e08d [file] [log] [blame]
<html>
<head>
<script>
function debug(str) {
li = document.createElement('li');
li.appendChild(document.createTextNode(str));
document.getElementById('console').appendChild(li);
}
function parseDocument() {
str = '<test><child1>First child</child1>';
str += '<child2 attr="an attribute">Second child</child2>';
str += '<!-- A comment --></test>';
parser = new DOMParser();
doc = parser.parseFromString(str, 'text/xml');
return doc;
}
function runTests() {
if (window.testRunner) {
testRunner.dumpAsText();
}
doc = parseDocument();
child1 = doc.documentElement.firstChild;
child2 = child1.nextSibling
comment = child2.nextSibling;
fragment = doc.createDocumentFragment();
fragment.appendChild(doc.documentElement.cloneNode(true))
serializer = new XMLSerializer();
debug(serializer.serializeToString(child1));
debug(serializer.serializeToString(child2));
debug(serializer.serializeToString(comment));
debug(serializer.serializeToString(doc));
debug(serializer.serializeToString(fragment));
}
</script>
</head>
<body onload="runTests()">
This tests XMLSerializer on different node types. If the test is successful, there should be five lines of output. The first line should be the child1 tag. The second should be the child2 tag. The third one should be a comment, the fourth one should be the complete document and the fifth one should be the complete document but serialized from a document fragment node.
<ul id="console">
</ul>
</body>
</html>