przemoinho
przemoinho

Reputation: 201

Change tag name in XML

I have exception like this:

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"tax"). Expected elements are <{}TaxGroup>

I have resposne which is String and look like this:

<?xml version="1.0" encoding="utf-8"?>
<tax xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <xml_message_type>tax</xml_message_type>
    <version>
        <xml_version>1.0</xml_version>
    </version>
</tax>

How to iterate over this XML and repleace tag name tax with TaxGroup ?

Upvotes: 0

Views: 86

Answers (1)

Vadim
Vadim

Reputation: 4120

It must mean that you try to unmarshal your XML which has a root element <tax> to Java Jaxb class which expects root element <TaxGroup> instead.

Definitelly XML does not match what unmarshaler was requested.

check what Java class do you expect to get out of this XML, and change it accordingly. Also check what element name defined in its JAXB annotation.

Upvotes: 1

Related Questions