diff options
author | Filipp Lepalaan <filipp@mac.com> | 2019-09-01 15:30:28 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2019-09-01 15:30:28 +0300 |
commit | f9e705045631ddb774d58e54e1101423e6b395d4 (patch) | |
tree | 7515f2b22dea233441305a708e620bdfe228de86 | |
parent | 4ea5f9d02a49bf303a9d268d8a40e8532f6009de (diff) | |
download | php_plist-f9e705045631ddb774d58e54e1101423e6b395d4.tar.gz php_plist-f9e705045631ddb774d58e54e1101423e6b395d4.tar.bz2 php_plist-f9e705045631ddb774d58e54e1101423e6b395d4.zip |
For use with "mdls -plist -" et al.
-rw-r--r-- | PropertyList.php | 16 |
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") { |