Guest User

Untitled

a guest
Jun 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. function validate_xml($source) {
  4. if ($source == '') return true;
  5.  
  6. $document = new DOMDocument();
  7. $fragment = $document->createDocumentFragment();
  8.  
  9. return @$fragment->appendXML($source);
  10. }
  11.  
  12. $source = @$_POST['source'];
  13. $valid = (validate_xml($source) ? 'yes' : 'no');
  14.  
  15. ?>
  16. <form action="" method="post" style="width: 60em">
  17. <textarea name="source" style="height: 40em; width: 100%;"><?php echo htmlentities($source); ?></textarea>
  18. <div>
  19. <button style="float: right;" type="submit">Validate</button>
  20. <span>Valid: <?php echo $valid; ?></span>
  21. </div>
  22. </form>
Add Comment
Please, Sign In to add comment