I am working with the eBay Trading API and part of one of the API calls comes back with an ItemSpecifics array of XML elements, a simple example is below:
<ItemSpecifics>
<NameValueList>
<Name>Brand</Name>
<Value>My1stWish</Value>
<Source>ItemSpecific</Source>
</NameValueList>
</ItemSpecifics>
So we have the attributes Name and Value being returned.
Not every item comes back with the same set of Name attributes, some eBay listings may have none, some may have 20 and those 20 completely differ from the next listing with have 15 different ones.
So my question is: How would you suggest handling these attribute values, so that they can be stored into a MySQL database table and then be able to be pulled back out from that table, with the values that have been set with the right Name as the header and corresponding Value?
Should I just dump these as serialised data into the table for a column called 'ItemSpecifics'? But then I'm not sure how I get them back out again so that I can create a flat file with the all options as headings in say a CSV file.
Two examples below:
Listing 1 returns:
<ItemSpecifics>
<NameValueList>
<Name>Brand</Name>
<Value>My1stWish</Value>
<Source>ItemSpecific</Source>
</NameValueList>
<NameValueList>
<Name>Exact Colour</Name>
<Value>Black</Value>
<Source>ItemSpecific</Source>
</NameValueList>
</ItemSpecifics>
Listing 2 returns:
<ItemSpecifics>
<NameValueList>
<Name>Exact Heel Height</Name>
<Value>4.1"</Value>
<Source>ItemSpecific</Source>
</NameValueList>
<NameValueList>
<Name>Heel Type</Name>
<Value>Stiletto</Value>
<Source>ItemSpecific</Source>
</NameValueList>
</ItemSpecifics>