This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

XmlBeans  RSS feed

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

I am learning XMLBeans which is an open source tool to convert from XML to java beans.

I want to know if using XMLBeans we can convert from Java beans to XML. Is that possible?

Also , say we have an xml file, is it possible to parse that xml using
XMLBeans API?

thanks very much
Jay
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am learning XMLBeans which is an open source tool to convert from XML to java beans.

I want to know if using XMLBeans we can convert from Java beans to XML. Is that possible?


Yes it is. First step is to create a schema file and then compile
it with the scomp tool. This will generate a jar file containing the
java classes that map to the elements in your schema.

The next bit is bit trickier. The generated files do not include the source. So you're going to have to use javap to generate the byte code.
Using this and a bit of trial and error, you can work out how to use
the various classes. This bit is time consuming and a little annoying,
so if anybody out there has a better way of doing this, please post
a note. Once you've figured out how to use the classes, populate them
with data in your application. When you're ready, call the .toString()
method on the root node and this will generate your xml. BINGO !!!


Also , say we have an xml file, is it possible to parse that xml using
XMLBeans API?

Not quite sure with this one. I have'nt looked at this. If you do find out
please post a note.

kind regards,
Mo


[ May 22, 2007: Message edited by: mo sayed ]
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!