Im trying to create a page for a university project that dynamically displays a list of videos in a flash player from data stored in a Mysql database. i already have the player running correctly from a simple XML list but I need to get the right data from the database and convert it to an XML list to display the playlist according to the currently selected video.
The XML list looks like this:
<?xml version="1.0" encoding="utf-8"?>
<item>
<list name="A really awesome video of Declan's face." videotitle="Declan Video" link="0001.flv" >
<thumb>thumb/1.jpg</thumb>
</list>
<list name="Test content - Video of Wenlong and Jing" videotitle="Final matrix demo 2" link="test1.flv" >
<thumb>thumb/2.jpg</thumb>
</list>
<list name="Video of Wenlong and Jing" videotitle="Matrix film demo 1" link="test2.flv" >
<thumb>thumb/1.jpg</thumb>
</list>
<list name="Video of Wenlong and Jing" videotitle="Final matrix demo 2" link="test4.flv" >
<thumb>thumb/2.jpg</thumb>
</list>
<list name="Video of Wenlong and Jing" videotitle="Matrix film demo 1" link="wenlong1.flv" >
<thumb>thumb/1.jpg</thumb>
</list>
</list>
</item>
Any ideas on how to best achieve this? Help would be greatly appreciated.
Thanks!
Have you tried just manually creating the XML file using XDocument from your results set?
Now you havent provided any sample code for getting the data out of your MySql server, or no examples that should the parameters for reading the mysql data storeage. With little information can really just provide you with a basic method that takes a data table (with specific column names) and returns a simple formatted xml document.
That little snippet is simple, it simply accepts the datatable as a parameter and then creates a XDocument for you. Now the requirements are the datatable must have the columns name, videotitle, link and thumb.
Now moving on you can simply call this method which will return the XDocument object, from there calling the .ToString() method of the XDocument will give you your xml. However there is a catch (there’s always a catch). The XDocument doesnt include the Xml Declaration when the .ToString() method is called. If you call the .Save() method it will output the Xml Declaration.
I have another simple method that allows you to output the XDocument to a string with the Xml Declaration intact. This methods is as follows.
You see that method will call the Save() method of the xDocument however will save it to a MemoryStream and then output the memorystream as a string.
Now to tie it all together I have a simple console application that you can have a look at and understand how it all fit together.
I hope this helps.
Cheers,
Nico