我有以下的xml字符串。我想将其转换为一个Java对象,将每个标签映射到该对象的字段。最好是可以引入与标签名称不同的字段名称。我应该如何做?我正在寻找JAXB的解决方案,但仍然对“ns4:response”和嵌套标签等部分感到困惑。谢谢您提前的帮助。
<ns4:response>
<count>1</count>
<limit>1</limit>
<offset>1</offset>
<ns3:payload xsi:type="productsPayload">
<products>
<product>
<avgRating xsi:nil="true"/>
<brand>Candie's</brand>
<description>
<longDescription>
long descriptions
</longDescription>
<shortDescription>
short description
</shortDescription>
</description>
<images>
<image>
<altText>alternate text</altText>
<height>180.0</height>
<url>
url
</url>
<width>180.0</width>
</image>
</images>
<price>
<clearancePrice xsi:nil="true"/>
<regularPrice xsi:nil="true"/>
<salePrice>28.0</salePrice>
</price>
</product>
</products>
</ns3:payload>
</ns4:response>
ns4
等)没有被定义,所以你不能用标准工具解析它。 - artbristol