From d90eed75f0ba660a7a27832b3929681935547990 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Wed, 22 Nov 2017 00:19:44 +0100 Subject: [PATCH] Small fixes and optimisations in parsing. --- lib/TclUpdates/GotuObject.php | 5 +---- lib/TclUpdates/XmlParser.php | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/TclUpdates/GotuObject.php b/lib/TclUpdates/GotuObject.php index 5fb1eb7..ed5e4aa 100755 --- a/lib/TclUpdates/GotuObject.php +++ b/lib/TclUpdates/GotuObject.php @@ -17,10 +17,7 @@ class GotuObject return false; } $g = new self(); - $g->attrs['type'] = $xp->getAttr('type'); - $g->attrs['fv'] = $xp->getAttr('fv'); - $g->attrs['tv'] = $xp->getAttr('tv'); - $g->attrs['time'] = $xp->getReleaseTime(); + $g->attrs = $xp->getAttrs(); return $g; } } diff --git a/lib/TclUpdates/XmlParser.php b/lib/TclUpdates/XmlParser.php index 2fdb872..8b2a811 100644 --- a/lib/TclUpdates/XmlParser.php +++ b/lib/TclUpdates/XmlParser.php @@ -17,11 +17,11 @@ class XmlParser 'publisher' => '//VERSION/RELEASE_INFO/publisher', 'fw_id' => '//FIRMWARE/FW_ID', 'fileset_count' => '//FIRMWARE/FILESET_COUNT', - 'filename' => '//FILESET/FILE[0]/FILENAME', - 'file_id' => '//FILESET/FILE[0]/FILE_ID', - 'file_size' => '//FILESET/FILE[0]/SIZE', - 'file_chksum' => '//FILESET/FILE[0]/CHECKSUM', - 'file_version' => '//FILESET/FILE[0]/FILE_VERSION', + 'filename' => '//FILESET/FILE[1]/FILENAME', + 'file_id' => '//FILESET/FILE[1]/FILE_ID', + 'file_size' => '//FILESET/FILE[1]/SIZE', + 'file_chksum' => '//FILESET/FILE[1]/CHECKSUM', + 'file_version' => '//FILESET/FILE[1]/FILE_VERSION', 'description_en' => '//DESCRIPTION/en', 'description_ja' => '//DESCRIPTION/ja', 'description_zh' => '//DESCRIPTION/zh', @@ -60,6 +60,16 @@ class XmlParser return $node; } + public function getAttrs() + { + $attrs = array(); + foreach ($this->attr_map as $key => $xpath) { + $attrs[$key] = $this->getXPathValue($xpath); + } + $attrs['time'] = $this->getReleaseTime(); + return $attrs; + } + public function getReleaseTime() { $yr = $this->getXPathValue('//VERSION/RELEASE_INFO/year');