Code: Select all
<content>
<item>
<element type="h1">This is a heading</element>
<element type="p" id="title">This is a title</element>
<element type="p"><strong>Bold text:</strong> this is some text</element>
</item>
</content>Code: Select all
$xml=simplexml_load_file('article.xml');
foreach ($xml->item as $item){
foreach ($item->element as $element){
$type=$element['type'];
$id=$element['id'];
echo "<".$type." class=\"".$id."\">".$element."</".$type.">";
}
}
Also consider this div container with an image:
Code: Select all
<element type="div" id="image-left">
<img src="image1.jpg">
</element>Is my approach correct?
Thanks....