XMLReader

adicione uma nota

Notas Enviadas por Usuários (em inglês) 1 note

up
0
Anonymous
7 months ago
Allright, I'll do it myself:

$xmlreader = XMLReader::open('xml_file.xml');
$indent = 0;
while ($xmlreader->read() !== FALSE)
{
switch ($xmlreader->nodeType)
{
case XMLReader::ELEMENT:
echo str_repeat("\t", ($xmlreader->isEmptyElement ? $indent : $indent++)), '[element]: ', $xmlreader->name, "\n";
break;
case XMLReader::TEXT:
echo str_repeat("\t", $indent), $xmlreader->value, "\n";
break;
case XMLReader::END_ELEMENT:
echo str_repeat("\t", --$indent), '[end element]: ', $xmlreader->name, "\n";
break;
}
}
To Top