public loadFromFile ( $file ) : boolean | ||
return | boolean | whether the XML file is parsed successfully |
public function loadFromFile($file)
{
if (($str = @file_get_contents($file)) !== false) {
return $this->loadFromString($str);
} else {
throw new TIOException('xmldocument_file_read_failed', $file);
}
}
public function testLoadFromFile() { $file = dirname(__FILE__) . '/data/test.xml'; $xmldoc = new TXmlDocument(); try { $xmldoc->loadFromFile('unexistentXmlFile.xml'); self::fail('Expected TIOException not thrown'); } catch (TIOException $e) { } self::assertTrue($xmldoc->loadFromFile($file)); self::assertEquals('1.0', $xmldoc->getVersion()); self::assertEquals('UTF-8', $xmldoc->getEncoding()); }