• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Pull Parser

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

i need to write data in the form of Java Objects into XML documents. Is XML Pull parser a good choice for this task?
Can someone share a sample implementation for this?


Eric
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, no. Any XML parser -- pull or otherwise -- is for the purpose of converting XML documents into some internal form (such as Java objects). Your requirement is the other way around.
 
eric underwood
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, in that case, can you suggest some utility. I was under the impression that you can do xml-to-java as well as the other way round using these parsers.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Were you asking about StAX? It's one of the class of pull parsers, but it can also act as a serializer. Whether all instances of that class can serialize as well, I don't know. Probably not.

If that's the case then the trivial answer is yes. However you would have to write all the code which extracted the data from those objects and called the appropriate serializer methods. There isn't any Java-to-XML binding built into StAX that I'm aware of.
 
eric underwood
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the looks of it, seems like StAX (and hence XPP) isin't what I should use. Well, I don't HAVE to use XPP, so I am open to any other API. Can you suggest some?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This article gives a new XML databinding type using vtd-xml
http://onjava.com/pub/a/onjava/2007/09/07/schema-less-java-xml-data-binding-with-vtd-xml.html
reply
    Bookmark Topic Watch Topic
  • New Topic