Prev: Last chance for GR8 in the US conference $100 discount! Register now for the only Groovy, Grails, Griffon dedicated event in the US!
Next: Warning message with proprietary class
From: Tom Anderson on 3 Mar 2010 19:02 On Wed, 3 Mar 2010, markspace wrote: > Rhino wrote: > >> What are the best-regarded Java classes for writing XML these days? >> >> I'm afraid I've been out of touch with XML for a few years and long ago >> lost track of what is well-regarded in the Java community for creating XML >> files. >> >> I have a need to write an XML file but NOT to work with it any further; >> the file will be read by Microsoft Word but not processed any further. >> If someone can point me to some suitable classes for writing XML - and, >> ideally, a tutorial describing the proper use of these classes - I >> would really appreciate that. > > If you're going to program in Java, it would help to get some basic > references for these things for your bookshelf so you have them to refer to. > Maybe you do, and you just want to see what else might be out there, but it > kinda sounds like you need to get some more reference material. > > I'd recommend Learning Java, 3rd ed., by O'Reilly. Besides language > basics, LJ has a really huge number of chapters on the Java API, > including a nice section on XML. It covers the basics of the parsers > available, gives sample code for each one, and also gives a straight > forward comparison of each, which sounds like just what you need. You reckon? I'm not sure how much use any of the parser APIs are for writing XML. Parsing is traditionally very much about reading. Which is the opposite of writing. tom -- I never meant to say that the Conservatives are generally stupid. I meant to say that stupid people are generally Conservative. I believe that is so obviously and universally admitted a principle that I hardly think any gentleman will deny it. -- John Stuart Mill
From: markspace on 3 Mar 2010 19:59 Tom Anderson wrote: > You reckon? I'm not sure how much use any of the parser APIs are for > writing XML. Parsing is traditionally very much about reading. Which is > the opposite of writing. As far as I know, all of these parsers can also be used for writing, except for XPath.
From: Arne Vajhøj on 3 Mar 2010 20:09 On 03-03-2010 19:59, markspace wrote: > Tom Anderson wrote: >> You reckon? I'm not sure how much use any of the parser APIs are for >> writing XML. Parsing is traditionally very much about reading. Which >> is the opposite of writing. > > As far as I know, all of these parsers can also be used for writing, > except for XPath. A parser is by definition reading. But: W3C DOM : reading + in recent versions writing SAX : reading JAXB : reading + writing StAX : reading + writing JDOM : reading + writing So I would say 3.5 out of 5. XPath is not a parser but a query tool to be used with W3C DOM or JDOM. Arne
From: Jeff Higgins on 4 Mar 2010 06:30 Rhino wrote: > What are the best-regarded Java classes for writing XML these days? > > I'm afraid I've been out of touch with XML for a few years and long ago lost > track of what is well-regarded in the Java community for creating XML files. > > I have a need to write an XML file but NOT to work with it any further; the > file will be read by Microsoft Word but not processed any further. If > someone can point me to some suitable classes for writing XML - and, > ideally, a tutorial describing the proper use of these classes - I would > really appreciate that. > Given the information you've provided, some suitable Java classes are: BufferedWriter OutputStreamWriter FileOutputStream and the standard tutorials for these classes are here: <http://java.sun.com/docs/books/tutorial/essential/io/>. What do you really want to do?
From: Jeff Higgins on 4 Mar 2010 07:34
Stefan Ram wrote: > Jeff Higgins <oohiggins(a)yahoo.com> writes: >>> someone can point me to some suitable classes for writing XML - and, >> Given the information you've provided, > > Here is a full-blown XML writer, writing a complete XML document: > > public class XMLWriter > { public static void main( final java.lang.String[] args ) > { java.lang.System.out.println( "<a/>" ); }} > My XML editor reports that the output of your XMLWriter is well-formed. Rhino specified that he needs to write an XML file. public class XMLFileWriter { public static void main( final java.lang.String[] args ) throws java.io.IOException { new java.io.OutputStreamWriter( new java.io.FileOutputStream(args[0]), java.nio.charset.Charset.forName("UTF-8")).append("<a/>"); }} |