Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to convert query string into xml Structure

 
Gopi Chand Maddula
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4422
253
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic