parseEntry example

protected function parseFile(DOMDocument $xml): array
    {
        $entries = (new DOMXPath($xml))->query('//entries/entry');

        if (!$entries instanceof DOMNodeList || $entries->length === 0) {
            throw new RuntimeException('Required element "entry" is missing.');
        }

        $menu = [];
        foreach ($entries as $entry) {
            if ($entry instanceof DOMElement) {
                $menu[] = $this->parseEntry($entry);
            }
        }

        return $menu;
    }

    private function parseEntry(DOMElement $entry): array
    {
        $menuEntry = [];

        $menuEntry['isRootMenu'] = self::validateBooleanAttribute($entry->getAttribute('isRootMenu'));

        
Home | Imprint | This part of the site doesn't use cookies.