简体   繁体   中英

I have a feed in xml format with some atom elemets , how to convert them in to java objects

I need to convert this xml to java objects please suggest me how to do that or give me an example

is converting atom feed into java objects is same as xml to java pojos ??

  <feed xmlns="http://www.w3.org/2005/Atom">
   <link href="https://exampleatomfeed.com"
     rel="current"/>
   <link href="https://exampleatomfeed.com"/?limit=25&amp;search=&   amp;direction=backward"
     rel="self"/>
   <id>urn:uuid:6e392ca6-3f9e-4e70-a2ed-81306e216ee7</id>
    <title type="text">/events</title>
   <link href="https://exampleatomfeed.com"?marker=urn:uuid:35639090-   c125-4349-bc9f-73c5f28ae98a&amp;limit=25&amp;search=&amp;direction=forward"
     rel="previous"/>
   <link href="https://exampleatomfeed.com"marker=urn:uuid:d7c91521-59c7-47de-8ebc-dcc3f1cbd621&amp;limit=25&amp;search=&amp;direction=backward"
     rel="next"/>
   <link href="https://exampleatomfeed.com"?marker=last&amp;limit=25&amp;search=&amp;direction=backward"
     rel="last"/>
   <updated>2015-10-08T09:14:28.043Z</updated>
   <atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
  <atom:id>urn:uuid:35639090-c125-4349-bc9f-73c5f28ae98a</atom:id>
  <atom:category term="tid:965965"/>
  <atom:category term="rgn:ind"/>
  <atom:category term="dc:Ind"/>
  <atom:category term="iid:a0cb9f59-39f9-4dbc-b318-1d2121f8be8e"/>
  <atom:category term="example"/>
  <atom:category term="type:example"/>
  <atom:category term="example"/>
  <atom:category term="original_message_id:eda6dc40-f035-4ae5-931c-d214c184fa51"/>
  <atom:title type="text">Server</atom:title>
  <atom:content type="application/xml">
     <event xmlns="http://example.com"
            xmlns:gova="http://example.com"
            dataCenter="SYD2"
            endTime="2015-10-08T00:00:00Z"
            environment="PROD"
            id="35639090-c125-4349-bc9f-73c5f28ae98a"
            region="IND"
            resourceId="a0cb9f59-39f9-4dbc-b318-1d2121f8be8e"
            resourceName="RS-6"
            startTime="2015-10-07T00:00:00Z"
            tenantId="965965"
            type="USAGE"
            version="1">
        <nova:product bandwidthIn="127886662"
                      bandwidthOut="4236174"
                      flavorId="3"
                      flavorName="1GB Standard Instance"
                      isManaged="false"
                      osLicenseType="WINDOWS"
                      resourceType="SERVER"
                      serviceCode="ddfdffdf"
                      status="ACTIVE"
                      version="1"/>
     </event>
  </atom:content>
  <atom:link href="https://example.com/entries/urn:uuid:35639090-c125-4349-bc9f-73c5f28ae98a"
             rel="self"/>
  <atom:updated>2015-10-08T02:13:26.523Z</atom:updated>
  <atom:published>2015-10-08T02:13:26.523Z</atom:published>

That's possible using XML adapter when unmarshal. Look in this link:

http://aquiseprograma.co/2015/10/como-agregar-la-etiqueta-cdata-a-etiquetas-de-un-xml-generado-por-jaxb/

It's in spanish but is to easy understand. There is applying CDATA when marshal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM