File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How to convert query string into xml Structure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to convert query string into xml Structure" Watch "How to convert query string into xml Structure" New topic

How to convert query string into xml Structure

Gopi Chand Maddula
Ranch Hand

Joined: May 11, 2010
Posts: 40

Hi Java Ranch,

I am new to web technology. As i am familiar with core java technologies, i started woking on web technologies too.

I facing a problem in which i am getting a response from some server as a query string.
For Example the Query String looks like below....


and i must form an XML Structure based on that query string's key and value. I have no idea how to do it. Please help me by letting me know the best procedure to convert the query string into XML format.
Assume that the xml can be like this.

Thanks in Advance.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019

If the keys (parameters) are not pre-defined, you can use getParameterNames() method of HttpServletRequest to get an java.util.Enumeration object which contains the names of the parameters (keys). For getting the values, just iterate among the parameters through the Enumeration object and use getParameter(String) method of HttpServletRequest to get the value for each key.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
It is sorta covered in the JavaRanch Style Guide.
subject: How to convert query string into xml Structure
Similar Threads
Record store gets overwritten
Hashtable question!
midlet.platformRequest(string) problem for multiple request parameters in url
Properties API and escape charachers
How to Handle Properties