Re: XML Declaration
Martin Honnen <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
[email protected] wrote: > I would like to add an XML declaration to a Javascript generated > Document : > > var doc = document.implementation.createDocument("", "", null); > var rootElem = doc.createElement("toto"); > rootElem.setAttribute("version", "12334"); > doc.appendChild(rootElem); Note that you can shorten that to var doc = document.implementation.createDocument("", "toto", null); doc.documentElement.setAttribute("version", "12334"); > var serializer = new XMLSerializer(); > serializer.serializeToStream(doc, foStream, "UTF-8"); > > I get no <?xml ..?> at the beginning of the file ! Do you get one if you serialize to an encoding like ISO-8859-1 where the XML declaration is mandatory then? -- Martin Honnen http://JavaScript.FAQTs.com/