JDK 1.8 (необходимо использовать javax.xml.*)
Ожидается:
Код: Выделить всё
Neil Strauss
Strauss
Dhamma Gaweshi
Pearson
Colombo Airport
Colombo Bookstore
Код: Выделить всё
Neil
Strauss
978-0060554736
Dhamma Gaweshi
Pearson
Colombo Airport
Colombo Bookstore
Код: Выделить всё
package org.demo.eranga;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "book")
public class Book {
@XmlElement(name="authors/authorFirstName")
private String authorFirstName;
@XmlElement(name="authors/authorLastName")
private String authorLastName;
private String publisher;
private String isbn;
private String name;
public void setAuthorFirstName(String authorFirstName) {
this.authorFirstName= authorFirstName;
}
например:
@XmlElement(name= "authors/authorName")
частная строка имя автора;
Демонстрационный проект можно найти здесь, в git-хабе
Подробнее здесь: https://stackoverflow.com/questions/787 ... annotation