I would like to get Type, Id and Height values in database table. It is not working. There is no error message.
Objective is to get RESPECTIVE "Type" from Catalaog which has same Reference from Installed.
Well, I have 850 Mb XML file and i just would like to present small part of file:
XML:
<?xml version="1.0" encoding="utf-8"?>
<Physical>
<Catalog>
<EquipmentSpec>
<Reference>MAT_4</Reference>
<Type>Duplexeur</Type>
<Characteristic><CharacteristicName>Tilt</CharacteristicName>
<CharacteristicValue>0</CharacteristicValue></Characteristic>
</EquipmentSpec>
<EquipmentSpec>
<Reference>MAT_6890</Reference>
<Type>Node</Type>
<Characteristic><CharacteristicName>Tilt</CharacteristicName>
<CharacteristicValue>2</CharacteristicValue></Characteristic>
</EquipmentSpec>
<EquipmentSpec>
<Reference>MAT_50</Reference>
<Type>Single</Type>
<Characteristic><CharacteristicName>Tilt</CharacteristicName>
<CharacteristicValue>5</CharacteristicValue></Characteristic>
</EquipmentSpec>
</Catalog>
<Installed>
<Equipment>
<Id>26</Id><Reference>MAT_4</Reference>
<Characteristic><CharacteristicName>Height</CharacteristicName><CharacteristicValue>160</CharacteristicValue></Characteristic>
</Equipment>
<Equipment>
<Id>27</Id><Reference>MAT_6890</Reference>
<Characteristic><CharacteristicName>Height</CharacteristicName><CharacteristicValue>140</CharacteristicValue></Characteristic>
</Equipment>
<Equipment>
<Id>28</Id><Reference>MAT_50</Reference>
<Characteristic><CharacteristicName>Height</CharacteristicName><CharacteristicValue>180</CharacteristicValue></Characteristic>
</Equipment>
</Installed>
</Physical>
Code:
foreach ($xml->xpath('Physical') as $spec)
{
foreach ($spec->xpath('//EquipmentSpec') as $sub)
{
$Type = $sub->Type;
}
foreach ($spec->xpath('//Equipment') as $eq)
{
$Id = $eq->Id;
foreach ($eq->Characteristic as $c)
{
if ($c->CharacteristicName == 'Height')
{
$Height = $c->CharacteristicValue;
}
}
}
$sql = "INSERT INTO machines (`Type`,`Id`,`Height`) VALUES ('".$Type."','".$Id."','".$Height."')";
$req = new requete($site->db, $sql);
echo $sql;
}
EXPECTED output:
echo $Type;
$sql = "INSERT INTO LTE_noria_antennes (`Type`,`Id`,`Height`) VALUES ('{$Type}', '{$Id}', '{$Height}')";
$req = new requete($site->db, $sql);
It should insert in database table like this:
RefId** Type Id Height
1 Duplexeur 26 160
2 Node 27 140
3 Single 28 180
// **RefId is column auto_incriment to count rows.
I hope i am clear to you.
THANKS A LOT IN ADVANCED FOR YOUR INPUT.