• 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

constructing an xml string

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,
I have a small requirement. I have to read payment data and fill it up as an XML string using java. Can anybody help me please.. as I hardly know how to go about. depending on the type of payment the string should change slightly for ex. we have an extra element validuntil with month and year as attributes if the payment type is of credit card.
please suggest.
Thanks in advance.
cnu

Edit: I added the UBB [CODE] tags around your XML
[ February 01, 2004: Message edited by: Lasse Koskela ]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Writing XML is often easiest to do by hand.

If you go for this approach, do remember that it's up to you to make sure that the resulting XML is well-formed (characters are encoded correctly etc).
Another way would be to construct a DOM document by hand (see javaalmanac.com), and then serialize it into raw XML.
 
Pavan Kumar
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx a lot Lasse,
The link was pretty useful as well.
I was actually hard coding the string, and thought it may not be the right solution, hence wanted to take a different opinion. I don't really have to build a Documen object, parsing is all taken care of at the other end. I just have to send an xml string that's all.
Best regards,
cnu
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic