function validate()
 {
     if (!($dom_sxe = dom_import_simplexml($this->_xml))) {
         return false;
     }
     $dom = new DOMDocument("1.0");
     $dom_sxe = $dom->importnode($dom_sxe, true);
     $dom_sxe = $dom->appendchild($dom_sxe);
     return $dom->relaxNGValidate();
 }
Example #2
0
<?php 
} else {
    header('content-type:application/xml;charset=utf-8');
    header('cache-control:no-cache,must-revalidate');
    header('expires:fir,14 mar 1980 20:53:00 GMT');
    header('last-modified: ' . date('r'));
    header('pragma:no-cache');
    $dom = new DOMDocument('1.0');
    if (file_exists('guesebook.xml')) {
        $gb = simplexml_load_file('guesebook.xml');
        foreach ($gb->item as $item) {
            $gbit_arry[] = (int) $item->id;
        }
        $gbid = max($gbit_arry) + 1;
        $gb = dom_import_simplexml($gb);
        $gb = $dom->importnode($gb, true);
    } else {
        $gb = $dom->createelement('guestbook');
        $gbid = 1;
    }
    $gb = $dom->appendchild($gb);
    $item = $dom->createelement("item");
    //id
    $id = $dom->createelement('id');
    $text = $dom->createtextnode($gbid);
    $id->appendchild($text);
    $id = $item->appendchild($id);
    $user = $dom->createelement('user');
    $text = $dom->createtextnode(trim($_POST['user']));
    $user->appendchild($text);
    $user = $item->appendchild($user);