Advertisement
Guest User

schematest.php

a guest
Dec 13th, 2012
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2. $data_dom = new DOMDocument();
  3. $data_dom->load('test-data.xml');
  4.  
  5. // Multiple validations using the schemaValidate method.
  6. for ($attempt = 1; $attempt <= 3; $attempt++) {
  7.     $start = time();
  8.     echo "schemaValidate: Attempt #$attempt returns ";
  9.     if (!$data_dom->schemaValidate('test-schema.xsd')) {
  10.         echo "Invalid!";
  11.     } else {
  12.         echo "Valid!";
  13.     }
  14.     $end = time();
  15.     echo " in " . ($end-$start) . " seconds.\n";
  16. }
  17.  
  18. // Loading schema into a string.
  19. $schema_source = file_get_contents('test-schema.xsd');
  20.  
  21. // Multiple validations using the schemaValidate method.
  22. for ($attempt = 1; $attempt <= 3; $attempt++) {
  23.     $start = time();
  24.     echo "schemaValidateSource: Attempt #$attempt returns ";
  25.     if (!$data_dom->schemaValidateSource($schema_source)) {
  26.         echo "Invalid!";
  27.     } else {
  28.         echo "Valid!";
  29.     }
  30.     $end = time();
  31.     echo " in " . ($end-$start) . " seconds.\n";
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement