Soldato
- Joined
- 4 Mar 2010
- Posts
- 5,038
If that's the wrong way to do it would this be the right way to do it?
PHP:<? $bookname = 'Gone with the wind'; echo '<?xml version="1.0"?> <Book> <bookname>',$bookname,'</bookname> </Book>'; ?>
I'm only asking as I want to improve my coding practices.![]()
If it we're me I would get the info from a db or flat file, whatever and loop an array echoing the opening tag, value, then closing tag.
I would always use the longer tag <?php as it won't mess with it
PHP:
<?xml version="1.0"?>
<book>
<?php
#Db stuff goes here
$bookname = array("Book 1","Book2","Book3");
foreach ($bookname as $name)
{
echo "<bookname>$name</bookname>\n";
}
?>
</book>
To be honest I haven't used xml for ages, I believe there is also a xml class which you can implement too.
Last edited: