tags:

views:

27

answers:

3

i want to create a JTree resembling XML dom in java.. below is the XML form...

<html>
  <head>
    <title></title>
    <style></style>
    <body></body>
  </head> 
  <head>
    <title></title>
    <style></style>
    <body></body>
  </head>
</html> 

i want to create this tree structure....

A: 

There is a full example here: http://www.cafeconleche.org/books/xmljava/chapters/ch06s05.html

Pierre
A: 

Have a look at this article

org.life.java
A: 

You can do it easily by parsing the XML and creating a DefaultMutableTreeNode for each XML element. Tree nodes have parents and children just like XML elements so the mapping is easy.

If you set the Element as the user object in DefaultMutableTreeNode you will probably want to provide a custom TreeCellRenderer.

Qwerky