1
0
mirror of https://github.com/mbirth/tcl_update_db.git synced 2024-12-27 04:54:08 +00:00

Small fixes and optimisations in parsing.

This commit is contained in:
Markus Birth 2017-11-22 00:19:44 +01:00
parent 304dc11190
commit d90eed75f0
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
2 changed files with 16 additions and 9 deletions

View File

@ -17,10 +17,7 @@ class GotuObject
return false; return false;
} }
$g = new self(); $g = new self();
$g->attrs['type'] = $xp->getAttr('type'); $g->attrs = $xp->getAttrs();
$g->attrs['fv'] = $xp->getAttr('fv');
$g->attrs['tv'] = $xp->getAttr('tv');
$g->attrs['time'] = $xp->getReleaseTime();
return $g; return $g;
} }
} }

View File

@ -17,11 +17,11 @@ class XmlParser
'publisher' => '//VERSION/RELEASE_INFO/publisher', 'publisher' => '//VERSION/RELEASE_INFO/publisher',
'fw_id' => '//FIRMWARE/FW_ID', 'fw_id' => '//FIRMWARE/FW_ID',
'fileset_count' => '//FIRMWARE/FILESET_COUNT', 'fileset_count' => '//FIRMWARE/FILESET_COUNT',
'filename' => '//FILESET/FILE[0]/FILENAME', 'filename' => '//FILESET/FILE[1]/FILENAME',
'file_id' => '//FILESET/FILE[0]/FILE_ID', 'file_id' => '//FILESET/FILE[1]/FILE_ID',
'file_size' => '//FILESET/FILE[0]/SIZE', 'file_size' => '//FILESET/FILE[1]/SIZE',
'file_chksum' => '//FILESET/FILE[0]/CHECKSUM', 'file_chksum' => '//FILESET/FILE[1]/CHECKSUM',
'file_version' => '//FILESET/FILE[0]/FILE_VERSION', 'file_version' => '//FILESET/FILE[1]/FILE_VERSION',
'description_en' => '//DESCRIPTION/en', 'description_en' => '//DESCRIPTION/en',
'description_ja' => '//DESCRIPTION/ja', 'description_ja' => '//DESCRIPTION/ja',
'description_zh' => '//DESCRIPTION/zh', 'description_zh' => '//DESCRIPTION/zh',
@ -60,6 +60,16 @@ class XmlParser
return $node; 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() public function getReleaseTime()
{ {
$yr = $this->getXPathValue('//VERSION/RELEASE_INFO/year'); $yr = $this->getXPathValue('//VERSION/RELEASE_INFO/year');