aspose file tools*
The moose likes XML and Related Technologies and the fly likes Reading XML file to populate text fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Reading XML file to populate text fields" Watch "Reading XML file to populate text fields" New topic
Author

Reading XML file to populate text fields

James Howerton
Ranch Hand

Joined: Mar 14, 2009
Posts: 82
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

Joined: Mar 14, 2009
Posts: 82
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

Joined: Aug 15, 2004
Posts: 2874
Try looking at JAXP, that sounds appropriate for your case.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42646
    
  65
The XmlFaq links to several introductory articles regarding XML processing in Java. Using the SAX API it's pretty easy to handle specific tags.


Ping & DNS - my free Android networking tools app
James Howerton
Ranch Hand

Joined: Mar 14, 2009
Posts: 82
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
Bartender

Joined: Oct 14, 2005
Posts: 18910
    
    8


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

Joined: Mar 14, 2009
Posts: 82
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

Joined: Mar 14, 2009
Posts: 82
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
Marshal

Joined: Mar 22, 2005
Posts: 42646
    
  65
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

Joined: Mar 14, 2009
Posts: 82
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading XML file to populate text fields