getElementsByTagName($name)->item(0)->nodeValue; } function get_doc(): DOMDocument { $doc = new DOMDocument(); $path = "/home/maks/school/clientApps/mlos/src/db.xml"; $doc->load($path); return $doc; } function get_data(): array { $doc = get_doc(); $out = []; $games = $doc->getElementsByTagName("game"); $i = 0; while ($game = $games->item($i++)) { $out[] = [ "id" => $game->getAttribute("id"), "order" => $game->getAttribute("order"), "name" => get_node_value($game, "name"), "thumbnail" => get_node_value($game, "thumbnail"), "author" => get_node_value($game, "author"), "magazine" => get_node_value($game, "magazine"), ]; } usort($out, function ($a, $b) { return $a["order"] - $b["order"]; }); return [$out, $doc->getElementsByTagName("count")->item(0)->nodeValue]; } $doc = get_doc(); $xpath = new DOMXpath($doc); $game = $xpath->query('//game[@id="2"]/name')->item(0); // var_dump($game);