I have PHP code to turn an XML file into a CSV file. During testing, I do not create a CSV file, I simply repeat the results in CSV format.
Whenever an XMLReader reaches an empty element, it displays all the attributes of the element.
1) Is there a way to display the attribute name with its values โโie (is there a value of $ xml-> AttributeName that matches the value of $ xml->)?
2) Is there a sorting method for all attributes in the whole tree, and not just in an empty element?
<?php ini_set('memory_limit','50M'); $x = file_get_contents('H8_data.xml'); $xml = new XMLReader(); $xml->open('H8_data.xml', null, 1<<19); $num = 1; while ($xml->read() && $num <= 2000) { if($xml->isEmptyElement) { if($xml->hasAttributes) { while($xml->moveToNextAttribute()) { echo $xml->value, ', '; } } echo '<br />'; $num++; } }
? >
source share