require_once 'XMLDB.php';
$xmldbtest = new XMLDB('text.xml');
if(!$xmldbtest->isLoaded()){
echo 'can\'t load test.xml
';
$xmldbtest = new XMLDB('config.xml');
if($xmldbtest->isLoaded()){
// Testing selectNode($from, $attributeName = null, $attributeValue = null, $childName = null, $childValue = null)
echo 'Testing empty selectNode
';
try {
$xmldbtest->selectNode();
}
catch(Exception $e){
echo $e->getMessage().'
';
}
echo 'Testing selectNode
';
$result = $xmldbtest->selectNode('item');
echo count($result).' results
';
echo 'Testing selectNode id=weather with pk
';
$result = $xmldbtest->selectNode('item', 'weather');
echo count($result).' results
';
echo 'Testing selectNode id=weather
';
$result = $xmldbtest->selectNode('item', null, array('id'=>'weather'));
echo count($result).' results
';
echo 'Testing selectNode visibility = true
';
$result = $xmldbtest->selectNode('item', null,null,array('visibility'=>'true'));
echo count($result).' results
';
echo 'Testing selectNode visibility = true and x = 32
';
$result = $xmldbtest->selectNode('item', null ,null,array('visibility'=>'true', 'x'=>'32'));
echo count($result).' results
';
echo '
Testing insertNode at XML root
';
if($xmldbtest->insertNode(array('name'=>'item', 'attributes'=>array('id'=>'test'), 'childs'=>array('visibility'=>'true', 'x'=>'33'))))
echo "ok
";
else
echo "ko
";
echo '
Testing updatingNodeAttribute with no insert
';
if($xmldbtest->updateNodeAttribute('item', array('id', 'links'), array('id', 'zelda')))
echo "ok
";
else
echo "ko
";
echo '
Testing updateNodeValue via attribute
';
if($xmldbtest->updateNodeValue('item', array('id', 'notes'), null, 'booga!'))
echo "ok
";
else
echo "ko
";
echo '
Testing deleteNode via pk
';
if($xmldbtest->deleteNode('item', 'test', null))
echo "ok
";
else
echo "ko
";
}else{
exit("can't load config.xml either");
}
}