|
-
December 5th, 2011, 05:28 AM
#1
Creation of GUI from contents of xml file
Hi,
I have an xml file containing a list of items as-
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
</catalog>
My question is: How do I code in java in order to display this in a tree structure in a GUI?
It should be displayed as:
bk105
Gambardella, Matthew
XML Developer's Guide
Computer
44.95
2000-10-01
An in-depth look at creating applications with XML.
bk102
Ralls, Kim
Midnight Rain
Fantasy
5.95
2000-12-16
A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.
Added to it, there should be an option to expand and compress the contents of the tree also.
Last edited by Aveeb4u; December 5th, 2011 at 06:14 AM.
-
December 5th, 2011, 08:08 AM
#2
Re: Creation of GUI from contents of xml file
If you think of a tree as such, it is very XML like. There are plenty of examples on how to use direct XML document for building tree components in Java. You can take a look at those, or implement your own. You can start with simple implementation of the TreeModel interface, leaving out editability and such for now. When that works, scaling the missing requirements is still simple enough to do.
thats just one example of many. This tutorial uses external convinience libraries that may / may not be accecible to your solution.
http://www.arsitech.com/xml/jdom_xml_jtree.php
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|