Skip to content

Instantly share code, notes, and snippets.

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

What would you like to do?
simplexml und xpath example
<?xml version="1.0" encoding="UTF-8"?>
<product tax="19" status="luxus">
<product tax="7" status="grundnahrung">
$xml = simplexml_load_file('data.xml');
$res = $xml->xpath('.//*[@tax]');
foreach( $res as $node ) {
$atts = $node->attributes();
printf( '%s ist %s und wird mit %d%% besteuert.<br>', $node->element, $atts['status'], $atts['tax'] );
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.