Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6823097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:44:31+00:00 2026-05-26T21:44:31+00:00

there is a small project im working on , in this project i have

  • 0

there is a small project im working on , in this project i have to display some data from an XML Source / file in a Vaadin tree.

My question is : can i do it with Vaadin tree and how “hard” would it be to realize it ?

i have looked at the Vaadin demo trees they are all using Containers as a source so dont know if it would work with XML.

Im new in XML and Java so fell free to post some usefull guides/links

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:44:32+00:00Added an answer on May 26, 2026 at 9:44 pm

    There are proablably a lot of java libraries out there for processing xml. Just take one, like XOM for example, and convert it to a HierarchicalContainer.

    For example, taking the XML reading example found here: http://bethecoder.com/applications/tutorials/xml-xom-read-xml.html and converting it to an IndexedContainer:

    <?xml version="1.0"?>
    <students>
        <student>
            <name>Sriram</name>
            <age>2</age>
        </student>
        <student>
            <name>Venkat</name>
            <age>29</age>
        </student>
        <student>
            <name>Anu</name>
            <age>28</age>
        </student>      
    </students>
    

    We can now modify the code there and throw the data into a container:

    Builder builder = new Builder();
    InputStream ins = ReadXML.class.getClassLoader()
          .getResourceAsStream("student_list.xml");
    
    //Reads and parses the XML
    Document doc = builder.build(ins);
    Element root = doc.getRootElement();
    
    IndexedContainer container = new IndexedContainer();
    container.addContainerProperty("name", String.class, null);
    container.addContainerProperty("age", Integer.class, null);
    //Get children
    Elements students = root.getChildElements();
    for (int i = 0 ; i < students.size() ; i ++) {
      System.out.println(" Child : " + students.get(i).getLocalName());
      Object student = container.addItem();
      Item studentItem = container.getItem(student);
    
      //Get first child with tag name as 'name'
      Element nameChild = students.get(i).getFirstChildElement("name");
      if (nameChild != null) {
        studentItem.getItemProperty("name").setValue(nameChild.getValue());
      }
      Element ageChild = students.get(i).getFirstChildElement("age");
      if (ageChild != null) {
          studentItem.getItemProperty("age").setValue(ageChild.getValue());
      }
    }
    

    now that indexedcontainer can be plugged into a table or tree. You can change it to a HierarchicalContainer if you have a tree format in your xml, and use setParent on the container. If you want to show multiple properties you’d have to go with the TreeTable instead of Tree, as Tree only shows one property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any small working program for recieving from and sending data to client
I'm currently working on a small project: there's a protocol for sending some strings
I am working on a small project and I need some help. I have
i'm working on a small project that might have an additional coder at some
This is for a small game project with SDL on MinGW/Windows. I am working
I am working in a small educational project where we have to implement a
I have a small c++ project I've been working on in XCode, that I'd
I'm working on a small project in C where I have to parse a
I'm working on a small project which will basically do some Facebook stuff and
Here is a scenario. I am working on a small project and in this,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.