• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert user input from GUI to .xml file  RSS feed

 
Chinmoy Padhi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Java Ranch,
Need some help on how to proceed with conversion of user input from GUI to .xml
As I am beginner in java, so please guide me.

My Requirement:
I want to create a GUI using Swing. The application will have various edit boxes where user can provide the input .

For example,
Origin-Host, Origin-Realm, Host-IP-Address etc. all these values must be provided by user.

The sample xml file should look like this:



So kindly suggest how I can create a GUI which will convert the user input to a xml file output.

Appreciate your help.
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I added code tags to your post, and doesn't it look better. Always use the tags; not they have an option to format XML. I also shortened the longer lines by dividing each into two lines and concluded that XML is intended for computers to read and not for people to read

Earlier, you wrote: . . . Need some help on how to proceed with conversion of user input . . . to .xml . . .
You also wrote:. . . conversion of user input from GUI . . .
Another thing you wrote:. . . I am beginner in java, so please guide me. . .
I am afraid I think those three statements are mutually incompatible. XML is not a beginner's topic. You should probably not write code to convert data to XML yourself, but search for an XML tutorial, or look for a book/chapter about XML. There is a chapter in Core JavaII by Horstmann and Cornell; in my 9th edition it is in Volume II pages 93‑174 approx. You will probably find there are classes which will do all the handling of the XML for you.
You should not worry about information from a GUI until after you have got the information translated to and from XML from the command line or a text file. Write a text file with the names of the properties related to their values. Lines 16‑26 of your XML might be written in a text file like this:-Now you can parse that file into tag names and tag values, but you will have to work out what to do about the magic comments about IPV4. Once you have got that working both ways, you will have the heart of the application and you can then write a GUI to go with it.

I am very surprised that sort of task has been given a beginner; what other programming experience do you have?
 
Chinmoy Padhi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell, I am working on java from last 4 months and prior to that I have worked on C++ using Qt5.0 version earlier. Since I am very much interested to learn java, so planning to work with Swing applications. Currently I am involve with Diameter protocol automation testing using JUnit3. For Diameter protocol I am using Seagull( to run and test manually), which is completely written with xml. So when I studied java and came across Swing , I thought to build a tool which will accept user input on the edit box or text box and it will convert those input to the desired output xml file which is equivalent of Seagull xml file. So that instead of manual intervention of changing Seagull xml we can run from the tool itself.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!