summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2005-11-11 20:47:02 +0000
committerxue <>2005-11-11 20:47:02 +0000
commit26ede97cc6771418af76a999931ccf5f4a8705a4 (patch)
tree95b3fa2e9834bfe0030cfd1eb29ddac985548070 /framework
parent5147906809d0fb77b75080da7fd0112a6f6f51f7 (diff)
Modified TXmlDocument::loadFromFile and loadFromString so that they return parsing status.
Diffstat (limited to 'framework')
-rw-r--r--framework/Data/TXmlDocument.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/framework/Data/TXmlDocument.php b/framework/Data/TXmlDocument.php
index f8ba5dc2..ba3df190 100644
--- a/framework/Data/TXmlDocument.php
+++ b/framework/Data/TXmlDocument.php
@@ -284,12 +284,13 @@ class TXmlDocument extends TXmlElement
/**
* Loads and parses an XML document.
* @param string the XML file path
+ * @return boolean whether the XML file is parsed successfully
* @throws TIOException if the file fails to be opened.
*/
public function loadFromFile($file)
{
- if(($str=file_get_contents($file))!==false)
- $this->loadFromString($str);
+ if(($str=@file_get_contents($file))!==false)
+ return $this->loadFromString($str);
else
throw new TIOException('xmldocument_file_read_failed',$file);
}
@@ -298,11 +299,13 @@ class TXmlDocument extends TXmlElement
* Loads and parses an XML string.
* The version and encoding will be determined based on the parsing result.
* @param string the XML string
+ * @return boolean whether the XML string is parsed successfully
*/
public function loadFromString($string)
{
$doc=new DOMDocument();
- $doc->loadXML($string);
+ if($doc->loadXML($string)===false)
+ return false;
$this->setEncoding($doc->encoding);
$this->setVersion($doc->version);
@@ -321,6 +324,8 @@ class TXmlDocument extends TXmlElement
if($child instanceof DOMElement)
$elements->add($this->buildElement($child));
}
+
+ return true;
}
/**