Skip to content

Instantly share code, notes, and snippets.

@RalfAlbert RalfAlbert/data.xml
Created Jan 29, 2013

What would you like to do?
PHP XMLReader class example
<?xml version="1.0" encoding="UTF-8"?>
<last_updated>2009-11-30 13:52:40</last_updated>
<product tax="19" name="luxus">
<product tax="7" name="brot">
$xml = new XMLReader();
$xml->open( 'data.xml' );
while( $xml->read() ) {
if( 'product' === $xml->name ) {
printf( '<hr>%3$s ist ein %1$s und hat eine Steuer von %2$d<br>', $xml->name, $xml->getAttribute('tax'), $xml->getAttribute('name') );

This comment has been minimized.

Copy link

magynhard commented Nov 12, 2015

How can you also output the "element" of every "product"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.