users@jaxb.java.net

Re: How to parse this xml

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Fri, 11 Apr 2014 15:37:07 +0200

The XML schema type for <listlertresponse> could be

   <xs:complexType name="ListAlertResponseType">
     <xs:sequbbence>
        <xs:element name="count" type="xs:integer">
        <xs:element name="alert" type="AlertType" maxOccurs="unbounded"/>
     </xs:sequence>
 </xs:sequeType>

This will give you an object with a List<AlertType> alert.

-W


On 11 April 2014 12:20, Xiaoliang Tian <xiaoliang.tian_at_gmail.com> wrote:

> Hi,
> My xml is as below
> <listalertsresponse cloud-stack-version="4.2.1">
> <count>24</count>
> <alert>
> <id>ccee51a5-a06e-4a3d-bf3c-364f59b022e0</id>
> <type>7</type>
> <description>Unable to eject host
> 9f522af4-3601-4af8-aee2-54e3f20ff650</description>
> <sent>2014-04-08T16:06:52+0900</sent>
> </alert>
> <alert>
> <id>0a4c098b-b95b-4251-99fd-25e0350b1e84</id>
> <type>7</type>
> <description>Migration Complete for host name: P1-C1-H6 (id:6),
> availability zone: Zone1, pod: Pod1</description>
> <sent>2014-04-08T16:04:58+0900</sent>
> </alert>
> </listalertsresponse>
>
> I know usually the element <alert> should be put inside the element
> <alerts>,So jaxb can easily parse this xml to object
>
> But How can I parse this kind of doc?
> Can u give me a example plz
>
> Best regards
>
>
>