• 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

converting HTML form to XML

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,
Merry Christmas,

Assume that there is a an HTML form in which end-user adds some data and submit it.
I wish to receive those data and convert them to XML so as to send them back to Server for further processing.

What solution do yo suggest? If JavaScript is suitable please tell me where can I find the code because I'm not familiar with JavaScript.

Cheers,
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript is not the most suitable technology for this. It'd be best to do this in Java code once the values get submitted to the server.
 
Mattew Lee
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:JavaScript is not the most suitable technology for this. It'd be best to do this in Java code once the values get submitted to the server.



Thanks for your answer, if I knew how to do it definitely I wouldn't ask this question, so would you please tell me how can I do this via Java code? please note that I want to
have the form's data in XML.

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XML doesn't make much sense without knowing what the schema should be. For example, these are all logical ways of representing a name:



Once you know what the data should look like, you can choose an XML parser such as DOM to build the XML. Or use String concatenation.

I'm going to move this to our XML forum for followups.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something is not clear to me - are you able to control the code on the server side or are you forced to deal with an existing server side application?


IF you control server side code, are you able to read form parameter values?


In any case, do you have an example XML document of what your output XML should look like?

Bill
 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I wish to receive those data and convert them to XML so as to send them back to Server for further processing.



I would suggest you to use XStream Api for easily converting Java Objects to XML and Vice versa , because its easier and avoids extra processing which in case if you go for DOM or SAX .

Thanks .
 
Mattew Lee
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:Something is not clear to me - are you able to control the code on the server side or are you forced to deal with an existing server side application?


IF you control server side code, are you able to read form parameter values?


In any case, do you have an example XML document of what your output XML should look like?

Bill



Example: Node names are similar to form tags. I control the server-side code.

<firstName>Data from form</firstname>
<lastName>Data from form</lastName>

Hope this helps
 
Mattew Lee
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravi Kiran Va wrote:

I wish to receive those data and convert them to XML so as to send them back to Server for further processing.



I would suggest you to use XStream Api for easily converting Java Objects to XML and Vice versa , because its easier and avoids extra processing which in case if you go for DOM or SAX .
Thanks .



Thanks, I will give it a try although if you had give me a complete example that would be great since I'm not a javaScript pro.

Regards,
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

There is nothing magic about XML, just a syntax requirement, so it doesn't matter how the elements get written.

Since you say you control the server side code, there appears to be no reason to do any creation of XML on the client side at all. Is there some reason you are not treating this as a normal form parameter processing problem?

If you absolutely have to send XML from the client, for some reason you have not explained, why not build the XML formatted request to send to the server by ordinary String writing?

Bill
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure why we are still talking about JavaScript. I think everyone in this thread agreed that Java/server side is the best place to start.

Now your decision is whether to just use String concatenation or a XML library.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic