I’m looking for a way to create a details page dynamically that correspond to an XML feed with PHP.
For example, say this is my xml feed:
<root>
<person>
<name>Jim</name>
<desc>A hard working guy.</desc>
</person>
<person>
<name>Tom</name>
<desc>As lazy as an obese house cat.</desc>
</person>
</root>
And say this was my php/html:
<?php
$dom = simplexml_load_file('people.xml');
?>
<ul>
<?php
for ($i = 0; $i < 10; $i++) {
$name = $dom->person[$i]->name;
$desc = $dom->person[$i]->desc;
$post =
'
<li>
<a href="details.php">'.$name.'</a>
<p>'.$desc.'</p>
</li>
';
echo $post;
}
?>
</ul>
I would like to have that <a> tag that’s being created link to a page that has the content of the corresponding person from the XML.
So I guess my two questions would be, how do I dynamically create a page with xml data, and how do I set the href attribute in the code above to link to it, in php?
Thank you for your insights and answers! 🙂
Try to use create using php in build function file_put_content(filename, content)
here i have created a files with usercontent0.php, usercontent1.php and so on
you can also specify some other random filenames and any thing that you want to add to the page will be added to the $post value