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');