0

I test simple xml tutorial from this link. I change the xml file like this.

<example xmlns:ns1="http://www.blah.com/ns/a">
  <a>
    <b>
        <x>abc</x>
      <ns1:x>blah</ns1:x>
    </b>
  </a>
</example>

and I add the following coding into the Example7 class.

   @Path("a/b")
   @Element(name = "x")
   private String x_;

I got this exception PersistenceException : Duplicate annotation of name 'x' on field 'x'. I would like to know how to overcome this exception.

Thanks.

4

1 回答 1

0

您需要x在类中注释您的字段Example7以使用命名空间ns1

@Element
@Path("a/b")
@Namespace(reference="http://www.blah.com/ns/a", prefix="ns1")
private String x;

另请参阅简单 XML 教程的相应部分

于 2013-12-16T18:41:15.037 回答