I want to convert xml data into html. Below is sample xml data and I want to get/convert it in html format.
<content type="html">
<paragraph id="1291266887">
<div class="red">
<span id="main_post_id">
<p>ten post przedstawia jak wysłać znaczników w ust <strong>Ling</strong> - xyz</p>
<p>tags znane jako <span class="translation_section section_2">bezpieczne</span>, będą traktowane jako sekcje pkt</p>
<p>innych materiałów dzielą się na <em>literach</em></p>
</span>
</div>
</paragraph>
</content>
i.e. I want to get all the html code contained between <paragraph id="..."></paragraph>
. I want to do it using php. When I convert it in array using php, it gives all data in array of div, p, span. But I want whole html contained in <paragraph>..</paragraph>
tag in a single array.
Please help needed here. Let me know best ways for this.
Thanks.
Write a XSLT stylesheet to convert it, and the xslt extension to apply it to the XML.
It's easy to use xslt in PHP. If you got the xml in file "data.xml" and the xslt-script in "script.xsl" this is all to do:
A simple xslt-script could look like this: