Example #1
0
 function __construct($gmlSource)
 {
     parent::__construct();
     include_once "libs/class_xml_check.php";
     $check = new XML_check();
     if ($check->check_string($gmlSource)) {
         print "GML is well-formed\n";
         //print("Elements      : ".$check->get_xml_elements());
         //print("Attributes    : ".$check->get_xml_attributes());
         //print("Size          : ".$check->get_xml_size());
         //print("Text sections : ".$check->get_xml_text_sections());
         //print("Text size     : ".$check->get_xml_text_size());
     } else {
         print "GML is not well-formed. ";
         print $check->get_full_error() . "\n";
         print "Script terminated\n";
         die;
     }
     $this->gmlSource = $gmlSource;
     $this->gmlCon = new gmlConverter();
     require_once "XML/Unserializer.php";
     $unserializer_options = array('parseAttributes' => TRUE);
     $unserializer = new XML_Unserializer($unserializer_options);
     // Serialize the data structure
     $status = $unserializer->unserialize($this->gmlSource);
     $this->gmlArray = $unserializer->getUnserializedData();
     print date('l jS \\of F Y h:i:s A') . " GML serialized\n";
     // Check if XML is a ServiceException
     if ($unserializer->getRootName() == "ServiceExceptionReport") {
         print "The server returned an exception:\n";
         print $this->gmlSource . "\n";
         print "Script terminated\n";
         die;
     }
 }
Example #2
0
<?php

include_once "class_xml_check.php";
$myxml = '<?xml version="1.0"?>
<foo>
 <data id="1">
   <name>pepe</name>
   <num>2</num>
 </data>
 <data>
   <name>foo</name>
   <num>5</num>
 </data>
</foo>';
$check = new XML_check();
//if($check->check_url("http://www.w3.org/")) {
if ($check->check_string($myxml)) {
    print "XML is well-formed<br/>";
    print "<pre>";
    print "Elements      : " . $check->get_xml_elements() . "<br/>";
    print "Attributes    : " . $check->get_xml_attributes() . "<br/>";
    print "Size          : " . $check->get_xml_size() . "<br/>";
    print "Text sections : " . $check->get_xml_text_sections() . "<br/>";
    print "Text size     : " . $check->get_xml_text_size() . "<br/>";
    print "</pre>";
} else {
    print "XML is not well-formed<br/>";
    print $check->get_full_error();
}