Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
metadatabuilder.php
1<?php
2
4
6{
7 protected $fileName;
8 protected $parser;
9
10 public function __construct($fileName)
11 {
12 if(!\Bitrix\Main\IO\File::isFileExists($fileName))
13 throw new \Bitrix\Main\ArgumentException('File is not found');
14
15 $this->fileName = $fileName;
16 $this->parser = new \Bitrix\Main\PhoneNumber\Tools\GoogleMetadata\Root();
17 }
18
19 public function build()
20 {
21 $xmlReader = new \XMLReader();
22 if ($xmlReader->open('file://'.$this->fileName) === false)
23 {
24 throw new \Bitrix\Main\SystemException("XMLReader could not open URI");
25 }
26
27 // looking for the root element
28 while ($xmlReader->read() && $xmlReader->nodeType !== \XMLReader::ELEMENT) ;
29
30 $parsedData = $this->parser->parseElement($xmlReader, '/');
31 $xmlReader->close();
32 unset($xmlReader);
33 return $parsedData['ROOT']['territory'];
34 }
35
36}