calmchess Posted July 14, 2010 Share Posted July 14, 2010 How do i select a single column with many rows from a mysql database and then use that selected data to generate a XML document? Quote Link to comment https://forums.phpfreaks.com/topic/207765-xml-generation/ Share on other sites More sharing options...
premiso Posted July 14, 2010 Share Posted July 14, 2010 By trying and finding some tutorials of how to do just that? http://articles.techrepublic.com.com/5100-10878_11-5035149.html Quote Link to comment https://forums.phpfreaks.com/topic/207765-xml-generation/#findComment-1086104 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 I've got to ask, which part of doing this do you need help with? It is a trivial coding task (replace document_tag and data_tag with your choice of tag name) - <?php // execute your query here ... echo '<?xml version="1.0" encoding="UTF-8" ?>'; // just in case the evil short open tags are on echo "<document_tag>"; while($row = mysql_fetch_assoc($result)){ echo "<data_tag>{$row['column_name']}</data_tag>"; } echo "</document_tag>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/207765-xml-generation/#findComment-1086123 Share on other sites More sharing options...
calmchess Posted July 14, 2010 Author Share Posted July 14, 2010 I thought there were some PHP XML methods used to build XML i had no idea you just formatted the xml and then write it. I don't know how exactly to form an xml tree so i'll have to learn thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/207765-xml-generation/#findComment-1086155 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 If you are writing the whole xml document based on data you have, it is simplest just to write the tags and data yourself. However, if you are modifying or iterating over an existing xml document, you would likely want to use a more sophisticated method. Quote Link to comment https://forums.phpfreaks.com/topic/207765-xml-generation/#findComment-1086159 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.