mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 16:46:26 +00:00
1b833f021f
by Anne van Kesteren <bug@annevankesteren.nl>, r+sr=bzbarsky
50 lines
1.3 KiB
HTML
50 lines
1.3 KiB
HTML
<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<?xml-stylesheet href="display.css" type="text/css"?>\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>
|