RetroZilla/extensions/xmlextras/tests/parseserialize.html

50 lines
1.2 KiB
HTML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<html>
<head>
<title>DOMParser/XMLSerializer test</title>
<style type="text/css">
.box {
display: box;
border: 1px solid black;
margin-bottom: 0.5em;
}
.boxheader {
font-weight: bold;
color: maroon;
}
pre {
margin-left: 2em;
}
</style>
<script type="text/javascript">
function execute()
{
var parser = new DOMParser();
var str =
'<?xml version="1.0"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<doc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n <d id="id3">Three</d>\n</doc>\n';
var doc = parser.parseFromString(str,"application/xml");
document.getElementById("id1").firstChild.nodeValue = str;
document.getElementById("id2").firstChild.nodeValue = doc;
var ser = new XMLSerializer();
document.getElementById("id3").firstChild.nodeValue = ser.serializeToString(doc);
}
setTimeout(execute,0);
</script>
</head>
<body>
<h1>DOMParser/XMLSerializer test</h1>
<div class="box"><span class="boxheader">text to parse</span>
<pre id="id1">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">document object</span>
<pre id="id2">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">document object serialized</span>
<pre id="id3">@@No result@@</pre>
</div>
</body>
</html>