How to structure repetitive elements and attributes across API responses



I want to map xml data returned from an API to class objects. Every response is inside the <response> tag along with the <status>, <start> and <total> tags. The rest of the content in the <response> could be a number of different things. In this example it is <Biographies> however it could be <Blogs>, <Reviews>, etc. How could I map this response to plain old object classes that could be reused for the parts that are in every response?



<response>
<status>...</status>
<start>0</start>
<total>2</total>
<biographies>
<biography>
<text>...</text>
<site>last.fm</site>
<url>http://ift.tt/15XOpIG;
<license>
<type>cc-by-sa</type>
<attribution>Last.fm</attribution>
<attribution-url>http://ift.tt/1ExAPe5;
<url>http://ift.tt/15XOpII;
<version>3.0</version>
</license>
</biography>
</biographies>
</response>

No comments:

Post a Comment