How to convert TreePath object into an XML file?

Discussion in 'Java' started by Prakash, May 11, 2004.

  1. Prakash

    Prakash Guest

    Hi,

    I want to convert the selected fields of a JTree, into an XML file.
    The getSelectionPaths() of JTree returns a TreePath[] object.
    But how do I convert this into an XML file?
    Is there any standard java API for that?

    NOTE: The JTree itself is constructed from an XML file.......

    Thanks in advance,
    Prakash.
     
    Prakash, May 11, 2004
    #1
    1. Advertising

  2. Prakash

    Salmo Bytes Guest

    Recurse down through the tree nodes
    For each node, call a function that builds the
    openning element. If that element has children,
    continue recursion, else complete the current element.

    public String mkXML(String xml, MyNodeType node)
    {
    xml += startNode(xml);
    Enumeration nodes = node.children();
    while(nodes.hasMoreElements())
    {
    subnode = (MyNodeType)node.nextElement();
    xml += mkXML(ret, subnode);
    }
    xml += endNode(node);
    return (xml);
    }
     
    Salmo Bytes, May 12, 2004
    #2
    1. Advertising

  3. Prakash

    Prakash Guest

    Any suggestions on this?

    (Prakash) wrote in message news:<>...
    > Hi,
    >
    > I want to convert the selected fields of a JTree, into an XML file.
    > The getSelectionPaths() of JTree returns a TreePath[] object.
    > But how do I convert this into an XML file?
    > Is there any standard java API for that?
    >
    > NOTE: The JTree itself is constructed from an XML file.......
    >
    > Thanks in advance,
    > Prakash.
     
    Prakash, May 12, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    3,149
    Andrew Thompson
    Jan 3, 2005
  2. Xenia
    Replies:
    4
    Views:
    444
    Xenia
    Nov 25, 2003
  3. Harry Zoroc
    Replies:
    1
    Views:
    963
    Gregory Vaughan
    Jul 12, 2004
  4. jkflens
    Replies:
    2
    Views:
    1,514
    jkflens
    May 30, 2006
  5. Aned
    Replies:
    2
    Views:
    510
    Roedy Green
    Sep 15, 2007
Loading...

Share This Page