comp.text.xml
[Top] [All Lists]

Re: SAX Parser for creating (not parsing) XML document

Subject: Re: SAX Parser for creating (not parsing) XML document
From: Stanimir Stamenkov
Date: Wed, 23 Jul 2008 08:04:44 +0300
Newsgroups: comp.text.xml


22 Jul 2008 16:31:54 GMT, /Stefan Ram/:

  Another way to write XML with pre-1.6-Java:

com.sun.org.apache.xml.internal.serialize.XMLSerializer serializer = new com.sun.org.apache.xml.internal.serialize.XMLSerializer ( fileOutputStream, outputFormat); serializer.startDocument(); { serializer.startElement("", "example", "example", new com.sun.org.apache.xml.internal.serializer.
        AttributesImplSerializer() );
      { final char[] data = "test text" . toCharArray();
        serializer.characters( data, 0, data.length );
        serializer.endElement( "", "example", "example" ); }
      serializer.endDocument(); }}}

Here's more standard way of doing it without requiring implementation specific classes (works with Java 1.4):

http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200801.mbox/%3c47972921.1020300@xxxxxxxxxxxx%3e

--
Stanimir

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy