Я этот XML:Демаршаллизация XML тег Джерси
<?xml version="1.0" encoding="utf-8"?>
<ProductItem xmlns="http://providers.natinst.com/pdi-rest/1.0/meta/" urn="urn:product-item:910796-76" url="http://immix-test2.natinst.com/pdi-rest/1.0/en-US/product-item/910796-76.xml">
<partNumber>910796-76</partNumber>
<inventoryItemId>560427</inventoryItemId>
<nicInventoryItemId>765430</nicInventoryItemId>
<name />
<description>LABVIEW CORE 2 SELF-PACED ONLINE TRAINING (6 MONTHS ACCESS)</description>
<isCustomerFacing>true</isCustomerFacing>
<itemType>CE</itemType>
<partType>Training Program</partType>
<bookingsClassName />
<bookingsClassCode />
<lifecyclePhase>Released</lifecyclePhase>
<salesClass />
<firstOrderableDate />
<locale>en-US</locale>
<ngpmProductHierarchy />
<productRevisions url="http://immix-test2.natinst.com/pdi-rest/1.0/en-US/product-item/910796-76/productRevisions.xml" />
<serviceOptionsForProduct url="http://immix-test2.natinst.com/pdi-rest/1.0/en-US/product-item/910796-76/serviceOptionsForProduct.xml" />
<serviceOptionsByService url="http://immix-test2.natinst.com/pdi-rest/1.0/en-US/product-item/910796-76/serviceOptionsByService.xml" />
<productFeatures url="http://immix-test2.natinst.com/pdi-rest/1.0/en-US/product-item/910796-76/productFeatures.xml" />
</ProductItem>
Я пытаюсь получить описание метки. Это мой код Java.
package com.ni.apps.elearningrest.client;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElementWrapper;
@XmlRootElement(name = "ProductItem")
public class DescriptionDTO {
private String description;
private String uri;
@XmlElement(name = "description")
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
}
Но я продолжаю получать "Неожиданный элемент (Uri: "http://providers.natinst.com/pdi-rest/1.0/meta/, местные:" ProductItem"). Ожидаемые элементы < {} ProductItem>»ошибка Что я могу сделать, чтобы исправить это
Хорошо, что присматривал за ошибки, но теперь, я не получаю описание. Есть идеи? – Nacho321
Хорошо, исправлено ... Я также добавил пространство имен в @XmlElement. Это выглядит как @XmlElement (name = "description", namespace = "htt p: //providers.natinst.com/pdi-rest/1.0/meta/"). Благодаря! – Nacho321