A
A
Alexander Asoskov2019-05-07 20:29:03
Java
Alexander Asoskov, 2019-05-07 20:29:03

How to keep part of the markup in the field as is when unmarshaling an xml document?

I struggle with the task for the second week. There is a document

<catalog>
 <books>
     ...........постоянно меняется  структура
 </books>
 <address>Павлова 45</address>
</catalog>

The books element can have a unique and unrepeatable structure.
Created a class
@XmlRootElement
    @Data
    @XmlAccessorType(XmlAccessType.NONE)
    @ToString
    static class Catalog{
        @XmlElement(name = "books")
        protected String books;
        @XmlElement(name = "address")
        protected String address;
    }

How to make protected String bookspure xml get into the property during mashaling and get the original xml back when unmarshaling?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BorLaze, 2019-05-07
@BorLaze

Check this question: Using JAXB to extract inner text of XML element

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question