Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
help.xml & xml.php
help.xml
========
<?xml version="1.0" encoding="utf-8" ?>
<help_context>
<screen>
<object>example a</object>
<name>testname a</name>
<id>_testid_a</id>
<bool>true</bool>
<text>This is a help-text</text>
</screen>
<screen>
<object>example b</object>
<extends>example a</extends>
<name>testname b</name>
<id>_testid_b</id>
</screen>
</help_context>
xml.php
=======
<?php
$xml = 'help.xml';
$x = simplexml_load_file( $xml );
$output = array();
foreach($x->screen as $screen_data){
$screen = (string) $screen_data->object;
$extends = (string) $screen_data->extends;
$output[$screen] = (array) $screen_data;
if( array_key_exists('extends', $screen_data )
&& array_key_exists($extends, $output)
){
$output[$screen] = array_merge($output[$extends], $output[$screen]);
}
}
var_dump($output);
echo 'Fertig.';
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.