0

The xml looks like below mentioned format and the name is "song.xml"

<song>
<id>1</id>
<title>sony</title>
</song>
<song>
    <id>4</id>
    <title>shal</title>
</song>
<song>
    <id>5</id>
    <title>eminem</title>
</song>
<song>
    <id>2</id>
    <title>cent</title>
</song>

The java bean class looks like below mentioned. Its name is "song.java"

 Class song {

    Public String id= null;
    Public String title= null;

   public int getid() {
        return id;
    }
    public void setid(int songNumber) {
        this.id = songNumber;
    }

    public int gettitle() {
        return title;
    }
    public void setid(String songTitle) {
        this.title = songTitle;
    }
}

My question is how can i parse the xml and set the value to the java bean?

Dinesh Ravi
  • 1,209
  • 1
  • 17
  • 35
  • Have you considered Smooks? http://www.smooks.org/ This allows you to bind XML to Java Beans. – Boris Jul 29 '14 at 11:04
  • 1
    Another good post: http://javarevisited.blogspot.co.uk/2013/01/jaxb-xml-binding-tutorial-marshalling-unmarshalling-java-object-xml.html – Boris Jul 29 '14 at 11:12

0 Answers0