File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes How to dynamically generate then POST xml data? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to dynamically generate then POST xml data?" Watch "How to dynamically generate then POST xml data?" New topic

How to dynamically generate then POST xml data?

James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
I'm new to XML and need to create a web app needs to do the following:
1. Read a couple of parameters (username and password) from the request
2. Dynamically create some xml code with those params
3. Send the xml code to another web service for validation

I am struggling with steps 2 and 3. Have been reading a lot on XML and SAX but the possible solutions I'm looking at seem really heavy. Is there a simple / straightforward way of doing what I need? Any code samples/snippets would be much appreciated.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13026
The simplest thing to do is just treat this as a problem in generating text and ignore the XML APIs.

If you can create/edit a text file that is a legal XML document containing example data, use that as a template and fill in the changing values at runtime.

I did this as a quick fix for a customer, so very very much simpler and faster than creating a DOM in memory and serializing it.

Another possibility would be to use JAXB .


Don't get me started about those stupid light bulbs.
subject: How to dynamically generate then POST xml data?
It's not a secret anymore!