Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading XML file to populate text fields

 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name of this question is read xml and set txtfields using combobox
Hello and Thank you in advance for any assistance.


System info:

netbeans,glassfish,MySQL

The Purpose of this post is:

I am trying to learn how to read an entire XML file and create an array that the selected index from a combo box will populate text Fields using the index to find the appropriate data.


The functionality of this code is:

I presently have a program that uses a combo box, a switch, and text fields set Text code to populate text fields according to the selected Item (the text) from a combo box.


My task is to build an XML file from the hard coded data (hundreds of set text statements. I am in the process of this now and I believe the blocks of tags will be

Code description

pseudo xml


My question is:

Are there any standards for performing this operation?
Thanks again.
-ceyesumma

Note:
………………………………………………………………………………………………

Code description


 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On creating the xml I realized that I first need to read the entire xml and learn how to find the tag <name> and populate the combo
box.


Could someone help me get started with the proper class or syntax to be using?

I have the first block of XML created and there will be 14 more to follow and my combobox will need to be created and populated properly.

right now I use an array to populate the combo box and an itemStateChanged(ItemEvent box) method. to show a new selected Item
so I would like to know the proper procedure for loading a combo box from xml.

 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try looking at JAXP, that sounds appropriate for your case.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The XmlFaq links to several introductory articles regarding XML processing in Java. Using the SAX API it's pretty easy to handle specific tags.
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked at the documentation for an unrelated SAX program and I working on loading a combobox as mentioned above.
I can not seem to get all the pieces in order to just read the keycard.xml and print it out. I guess that is where I start but the example was very confusing. Is it possible to read the xml like this






error:



also my keycard.xml was only found when I put it on the C:/ drive how can I use the keycard.xml if it is in the program package?
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You'll want to assign a value to this variable before you start using it. Otherwise you will get NullPointerExceptions (as you in fact are).
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how to assign a value to it. I did not see it set in the example. What values can I put in it?
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
off to a bad start with this one. not helpful examples at all

going to start over with

http://www.totheriver.com/learn/xml/xmltutorial.html

and then try the key words "Java xml tutorial". go figure. probably some good stuff there to.
Thanks for your time.

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how to assign a value to it. I did not see it set in the example. What values can I put in it?

Not so much put a value in it, but rather initialize it properly:

public Hashtable tags = new Hashtable();
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I did try that but it seemed like it throws the same exception and it indicates that it was at the end of the file.

I have started over with a new example. Still learning the tools.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic