filePath = $file; } } public function readFile() { if (!is_file($this->filePath)) { return; } $a = $this->tryCashTransaction(); $xml = simplexml_load_file($this->filePath, null, LIBXML_NOCDATA); $json = json_encode($xml); $arr = json_decode($json, true); $this->findValues($arr); } private function tryCashTransaction() { $obj = new \DOMDocument(); $obj->load($this->filePath); $node = $obj->getElementsByTagName("CashTransaction"); if (count($node) < 1) { return; } foreach ($node as $item) { $values = explode(" ", $item->getAttribute('description')); dd($values); } } private function findValues(array $arr) { $obj = new DividendsData(); $isset=false; foreach ($arr as $key => $value) { if (is_array($value)) { $this->findValues($value); } else { $isset=true; if ($key === "currency") { $obj->setCurrency($value); } if ($key === "payDate") { $tmp = str_split((string) $value, 4); $y=$tmp[0]; $tmp = str_split($tmp[1],2); $d = $tmp[1]; $m = $tmp[0]; // $a = implode("-", array_merge(str_split($tmp[1],2),$tmp[0])); // print_r($a); $obj->setDateTime(new \DateTime("$y-$m-$d")); } if ($key === "quantity") { $obj->setCount(intval($value)); } if ($key === "isin") { $obj->setIsin($value); } if ($key === "grossRate") { $obj->setValue(floatval($value)); } } } if ($isset) { $this->datas[] = $obj; } } }