I have a webservice from where I retrieve informations before updating a database.
I have to search for some values before inserting them, if i found them, obviously I will not insert them the xml should be like this:
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<categories>
<category id="10" xlink:href="http://www.server.it/B2B/api/categories/10"/>
</categories>
if it's full, otherwise :
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<categories>
</categories>
</prestashop>
after retrieve the xml i make :
$resources = $xml->children()->children();
if ($resources->category[@id] == ""){
insert category
}
now, all this code is working perfectly, but I must admit that those =="" is a bit awful, am I testing it in the right way? or is better some other kind of test? like isset, or null or whatever?