Speed up development with full-stack environments for every branch.

Learn More

Check if a xml document is valid [XMLReader and PHP]

1262 Runs 4786 Views 2394 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php
/*
 * PHP XMLReader - Check if a xml document is valid
 */

$reader = new XMLReader();
$reader->open('test.xml');

// Set parser options - you must set this in order to use isValid method
$reader->setParserProperty(XMLReader::VALIDATE, true);

if ($reader->isValid())
    echo "The XML is valid";
else
    echo "The XML is NOT valid";
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).