Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » How to rappresent XML in a tree field
icon3.gif  How to rappresent XML in a tree field [message #1231340] Tue, 14 January 2014 07:06 Go to next message
Eclipse UserFriend
Hi all,
I need to represent an XML file into a tree field with attribute and element; after that I need to enable the possibility to add, modify and delete node, element or attribute.

For the moment I use ScoutXmlParser, but I loose completely the attribute:

          ScoutXmlParser parser = new ScoutXmlParser();
          parser.setValidating(false);
          try {
            ScoutXmlDocument document = parser.parse(xml);
            ScoutXmlElement rootElement = document.getRoot();
            AbstractTreeNode root = getAbstractTree(rootElement.getLocalName());
            tree.addChildNode(tree.getRootNode(), root);
            this.recurse(tree, root, rootElement, rootElement.hasChildren());
            setTree(tree, false);
          }
          catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }

        public void recurse(Tree tree, AbstractTreeNode parent, ScoutXmlElement x, boolean b) {
          AbstractTreeNode child = null;
          if (b) {
            List<ScoutXmlElement> list = x.getChildren();
            for (ScoutXmlElement x1 : list) {
              child = this.getAbstractTree(x1.getLocalName());
              tree.addChildNode(parent, child);
              this.recurse(tree, child, x1, x1.hasChildren());
            }
          }
          else {
            if (x.hasContent()) tree.addChildNode(parent, this.getAbstractTree(x.getText()));
          }
        }


I think to enable the various function (add, modify and delete) by use a event listener.

Thanks in advance for any help and explanation
Re: How to rappresent XML in a tree field [message #1243817 is a reply to message #1231340] Tue, 11 February 2014 08:39 Go to previous messageGo to next message
Eclipse UserFriend
The problem is that on ScoutXmlElement exists no method to query all attributes if you do not know the attributes' names in advance.

As ScoutXmlParser itself is just a wrapper around other xml parsers you can just use such a parser directly.

Please note: In future ScoutXmlParser will possibly be deprecated and eventually removed. (See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=427899)

Re: How to rappresent XML in a tree field [message #1243901 is a reply to message #1243817] Tue, 11 February 2014 11:06 Go to previous message
Eclipse UserFriend
Ok, thank you Adrian for this information
Previous Topic:Replacing deprecated CTI classes
Next Topic:RAP theming Menu Bar
Goto Forum:
  


Current Time: Tue Jul 22 23:48:58 EDT 2025

Powered by FUDForum. Page generated in 0.03143 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top