I've been trying to parse an xml file and inserting the contents into my database, but I can't figure out how to insert the name & location for the store into one record.
My table looks something like this:
id | name | store | color | size | width | location
And my xml file looks like this:
<item>
<title>Boots</title>
<attributes>
<color>red</color>
<size>13</size>
<width>M</width>
</attributes>
<store>
<name>JCPenney</name>
<location>San Bruno</location>
<name>KMart</name>
<location>San Mateo</location>
</store>
</item>
I'm trying to insert the name and location in the same record, but when I do this:
foreach($item->store as $store) {
echo $store->name;
echo $store->location;
}
I only get one set. I get that it's because there's only one 'store' tag, but how do I pick up both the fields for each item, for each store?