summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2019-09-01 15:30:28 +0300
committerFilipp Lepalaan <filipp@mac.com>2019-09-01 15:30:28 +0300
commitf9e705045631ddb774d58e54e1101423e6b395d4 (patch)
tree7515f2b22dea233441305a708e620bdfe228de86
parent4ea5f9d02a49bf303a9d268d8a40e8532f6009de (diff)
downloadphp_plist-master.tar.gz
php_plist-master.tar.bz2
php_plist-master.zip
Allow loading plist as stringHEADmaster
For use with "mdls -plist -" et al.
-rw-r--r--PropertyList.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/PropertyList.php b/PropertyList.php
index c407011..b1d103b 100644
--- a/PropertyList.php
+++ b/PropertyList.php
@@ -12,12 +12,20 @@
class PropertyList
{
function __construct($xmlFile) {
- if (!file_exists($xmlFile)) {
- echo "{$xmlFile}: no such file";
+ $loaded = false;
+ $document = new DOMDocument();
+
+ if (file_exists($xmlFile)) {
+ $loaded = $document->load($xmlFile);
+ } else {
+ $loaded = $document->loadXML($xmlFile);
+ }
+
+ if ($loaded === false) {
+ echo "Failed to load input: {$xmlFile}";
return false;
}
- $document = new DOMDocument();
- $document->load($xmlFile);
+
$plistNode = $document->documentElement;
$this->root = $plistNode->firstChild;
while ($this->root->nodeName == "#text") {