I am so close to having this work. I have an xml that is not well formed but its the standard among Android Launchers so I have to figure out how to work with it.
I have it loading in my MySQL table but its loading ALL items for ALL categories. Let me show you what i mean.
<resources>
<version>1</version>
<category title="System" />
<item drawable="bluetooth" />
<item drawable="bluetooth_audio" />
<item drawable="browser" />
<item drawable="calculator" />
<item drawable="calendar" />
<item drawable="call_history" />
<item drawable="camera" />
<item drawable="clock" />
<item drawable="cmas" />
<item drawable="contacts" />
<item drawable="downloads" />
<item drawable="email" />
<item drawable="gallery" />
<item drawable="help" />
<item drawable="mailbox" />
<item drawable="messaging" />
<item drawable="phone" />
<item drawable="settings" />
<item drawable="supersu" />
<item drawable="superuser" />
<item drawable="superuser_koush" />
<item drawable="voice_commands" />
<item drawable="voice_search" />
<category title="Misc" />
<item drawable="apps" />
<item drawable="apps2" />
<item drawable="bigdx_clean" />
<item drawable="iconback" />
<item drawable="iconfront" />
<item drawable="text_apps" />
<item drawable="text_market" />
<item drawable="text_phone" />
<item drawable="text_sms" />
<item drawable="text_web" />
</resources>
Here is the PHP code that is currently parsing it
$apps = simplexml_load_file($ptmpName);
//loop through parsed xmlfeed and print output
foreach ($apps->category as $category) {
printf($category['title']);
$current_category = $category['title'];
foreach ($apps->item as $item) {
printf($item['drawable']);
$current_drawable = $item['drawable'];
//insert into databse
mysql_query("INSERT INTO user_drawable (user_ip, category,name)VALUES ('$ip',\"$current_category\",\"$current_drawable\")")
or die(mysql_error());
//show updated records
printf ("Records inserted: %d
", mysql_affected_rows());
}
}
So im ending up with all the item drawable entires duplicated for all category titles.
I need item drawable to match to category above it. everytime the category changes down the file the item drawable's row should change category