You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by we...@gmx.net on 2010/04/29 21:15:46 UTC

Best way to display xml in TreeView

Hi!

I have to show a xml file in a TreeView.
I'm currently browsing a Java DOM document and add the NodeValue to
TreeBranch or TreeNode depending on what it is in the document.

The TreeView looks good so far.
The problem is now that i have to show the xml code of selected nodes.
Well I can't get the attributes into the tree because TreeNode has only one
text.
But I need the attributes to identify the right node of which I show the XML
code right from the dom document.

The most nodes, which I have to show in detail, have an id attribute. But
how can I add the ID to the tree without actually showing it to the user?

thx!
regards

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Re: Best way to display xml in TreeView

Posted by Greg Brown <gk...@mac.com>.
This sample app demonstrates how you can use the org.apache.pivot.xml.Element class to display an XML hierarchy in a tree view. The root Element is actually used as the root node of the TreeView, saving the overhead of parsing the DOM and then walking it again to build the tree structure:

  http://svn.apache.org/repos/asf/pivot/trunk/tools/src/org/apache/pivot/tools/xml/

The app uses a custom node renderer to display the contents of each node. You might be able to do something similar in your app.

You can see a live demo of the app here:

  http://pivot.apache.org/demos/xml-viewer.html

Hope this helps,
Greg

On Apr 29, 2010, at 3:15 PM, weisswurst@gmx.net wrote:

> Hi!
> 
> I have to show a xml file in a TreeView.
> I'm currently browsing a Java DOM document and add the NodeValue to
> TreeBranch or TreeNode depending on what it is in the document.
> 
> The TreeView looks good so far.
> The problem is now that i have to show the xml code of selected nodes.
> Well I can't get the attributes into the tree because TreeNode has only one
> text.
> But I need the attributes to identify the right node of which I show the XML
> code right from the dom document.
> 
> The most nodes, which I have to show in detail, have an id attribute. But
> how can I add the ID to the tree without actually showing it to the user?
> 
> thx!
> regards
> 
> -- 
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01