Talk:PHP Parsing: Assets XML
From EVEDev
Nice try, but what if CCP Decides to try to SQL Inject your page? (Yea I know its unlikely, but never ever trust any 3rd party).
Also, this code will get into trouble when it comes to items that are inside each other, as it asumes a max-depth of 2. In fact there is no real limit on how deep that sh*t an stack.
example:
- you got a corp hangar array at a POS = 1
- you got a Ship inside that corp hangar array = 2
- you got a courier package inside that ship = 3
- you got a (assembled) ship in that courier package = 5
- you got a container inside that assembled ship = 6
- you got some items inside that container = 7
so it would be better to use a recursive function like this:
function process_child($element, $parrentID) {
foreach($element->rowset->row as $row) {
$a = $row->attributes();
mssql_query('INSERT INTO [eve_data].[dbo].[inventory] (
itemID, locationID, typeID, quantity, flag,
singleton, parrentID, owner) VALUES (
'.intval($a['itemID']).','.intval($a['locationID']).','
.intval($a['typeID']).','.intval($a['quantity']).','
.intval($a['flag']).','.intval($a['singleton']).','
.intval($parrentID).','.$GLOBALS['owner'].')');
if(count($row->children()) > 0) {
process_child($row, $a['itemID']);
}
}
}

