我有来自webservice的xml但是即使结构是标准的,我使用JAXB使用JAVA Spring解析这个文件时遇到了一些问题,结构是这样的:
<organisation>
<organisation>
<organisationIdentification>
<uid>
<uidOrganisationIdCategorie>123</uidOrganisationIdCategorie>
<uidOrganisationId>1234531234</uidOrganisationId>
</uid>
<OtherOrganisationId>
<organisationIdCategory></organisationIdCategory>
<organisationId></organisationId>
</OtherOrganisationId>
<OtherOrganisationId >
<organisationIdCategory></organisationIdCategory>
<organisationId></organisationId>
</OtherOrganisationId>
<organisationName>Orgnanisation name</organisationName>
<organisationLegalName">Name SA</organisationLegalName>
<legalForm >3698</legalForm>
</organisationIdentification>
<nogaCode>123456</nogaCode>
<contact>
<address>
<otherAddressCategory>main</otherAddressCategory>
<postalAddress>
<organisation >
<organisationName>Name SA</organisationName>
</organisation>
<addressInformation>
<street/>
<town></town>
<zipCode></zipCode>
<country>
<countryIdISO2></countryIdISO2>
<countryNameShort></countryNameShort>
</country>
</addressInformation>
</postalAddress>
</address>
<address>
<otherAddressCategory></otherAddressCategory>
<postalAddress>
<organisation>
<organisationName>-</organisationName>
</organisation>
<addressInformation>
<street></street>
<town></town>
<zipCode></zipCode>
<country>
<countryIdISO2></countryIdISO2>
<countryNameShort></countryNameShort>
</country>
</addressInformation>
</postalAddress>
</address>
<address>
<otherAddressCategory>postbox</otherAddressCategory>
<postalAddress>
<organisation>
<organisationName>-</organisationName>
</organisation>
<addressInformation>
<street/>
<postOfficeBoxNumber></postOfficeBoxNumber>
<postOfficeBoxText/>
<town/>
<zipCode></zipCode>
<country>
<countryIdISO2></countryIdISO2>
<countryNameShort></countryNameShort>
</country>
</addressInformation>
</postalAddress>
</address>
<email>
<emailAddress>info@mail.ch</emailAddress>
</email>
<internet>
<internetAddress>http://www.site.ch</internetAddress>
</internet>
</contact>
<languageOfCorrespondance>IT</languageOfCorrespondance>
</organisation>
<uidregInformation>
<uidregSource>
<uidOrganisationIdCategorie></uidOrganisationIdCategorie>
<uidOrganisationId >11111111</uidOrganisationId>
</uidregSource>
<uidregSource>
<uidOrganisationIdCategorie>CHE</uidOrganisationIdCategorie>
<uidOrganisationId>23232111</uidOrganisationId>
</uidregSource>
<uidregSource>
</uidregInformation>
</organisation>
JAXB可以将此文件解析为类模型,并保留多个节点的所有值(uidOrganisationId / town / zipCode)。 我不知道如何存储具有相同节点的值。