<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sheeraz Ahmed Memon</title>
    <description>The latest articles on DEV Community by Sheeraz Ahmed Memon (@sheerazam).</description>
    <link>https://dev.to/sheerazam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F768116%2F6d5717df-9adc-4a95-8c3b-132cc7de2a22.png</url>
      <title>DEV Community: Sheeraz Ahmed Memon</title>
      <link>https://dev.to/sheerazam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sheerazam"/>
    <language>en</language>
    <item>
      <title>How to Parse XML using Kotlin in 2021</title>
      <dc:creator>Sheeraz Ahmed Memon</dc:creator>
      <pubDate>Sat, 04 Dec 2021 13:56:53 +0000</pubDate>
      <link>https://dev.to/sheerazam/how-to-parse-xml-using-kotlin-in-2021-23bb</link>
      <guid>https://dev.to/sheerazam/how-to-parse-xml-using-kotlin-in-2021-23bb</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;In 2021, Lots of APIs are written using JSON. But there are some API in some domains like healthcare, traveling and web streaming that return XML. XML is a terrible serialization format, it wasn’t initially, but has been misused for decades and abused by many a software development engineer out in the wild.&lt;/p&gt;

&lt;p&gt;When you want to interact with one of these XML, you might cry or shake your fist initially.&lt;/p&gt;

&lt;p&gt;But no more.&lt;/p&gt;

&lt;p&gt;We can now use Simple XML library in Kotlin that does the heavy load, parses XML and gives the POJO (Plain old java object) magically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps:
&lt;/h2&gt;

&lt;p&gt;So here is the XML we will use in this example, and parse it&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;First add Simple XML library in Gradle.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Now let's create POJO’s&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Now that POJO’s are created, we can parse it using the following code&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;val serializer: Serializer = Persister() val dataFetch = serializer.read(DataFetch::class.java, xmlToParse)&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Easy, right, here is a test to check the parsing.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;div class="ltag__link"&gt;
  &lt;a href="https://sheerazmemonway.medium.com/how-to-parse-xml-using-kotlin-in-2021-21f2fffbdf22" class="ltag__link__link" rel="noopener noreferrer"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afill%3A88%3A88%2F1%2A_DgA7DB1_sN4EjUS_G-VbQ.png" alt="Sheeraz Ahmed Memon"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://sheerazmemonway.medium.com/how-to-parse-xml-using-kotlin-in-2021-21f2fffbdf22" class="ltag__link__link" rel="noopener noreferrer"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;How to Parse XML using Kotlin in 2021 | by Sheeraz Ahmed Memon | CodeChai | Medium&lt;/h2&gt;
      &lt;h3&gt;Sheeraz Ahmed Memon ・ &lt;time&gt;Oct 6, 2024&lt;/time&gt; ・ 
      &lt;div class="ltag__link__servicename"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fmedium-f709f79cf29704f9f4c2a83f950b2964e95007a3e311b77f686915c71574fef2.svg" alt="Medium Logo"&gt;
        sheerazmemonway.Medium
      &lt;/div&gt;
    &lt;/h3&gt;
&lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>android</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
