GeeCON Prague 2014*
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
Author

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....

key1=value1&key2=value2&key3=value3&key4=value4&key5=value5&key6=value6

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: 3112
    
  42

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
 
 
subject: How to convert query string into xml Structure