Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting String to XML

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am passing a a full XML representation as a string between two programs, Please how steps do i need to "cast" the String to an XML Element
 
Dan Walin
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "cast" it implies that an xml element is a java type. I may be wrong but, in my experience, I always create an XML just like you'd create a String (appending tags and values as needed). I usually have all the values as fields in a class (CMRAll in my example) so I can loop through all the fields to create the element names and values using the Class class in a method I call "xmlIt". The result is a String with the entire xml structure, like this:



I'm willing to listen to someone with a better idea since I am relatively new to creating xml from my code.
 
Hendrik Louw
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at JDom.
It's a very simple XML DOM API (Man that's a lot af TLA's )
 
Paul Clapham
Sheriff
Pie
Posts: 20955
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to parse that String into a DOM, let's say?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic