Last post Apr 30, 2011 02:37 PM by Chumley Walrus
Mar 17, 2011 03:23 PM|Chumley Walrus|LINK
I have an mp3 player that draws its playlist content from an xml file:
<?xml version="1.0" encoding="UTF-8"?><player showDisplay="yes" showPlaylist="yes" autoStart="yes" topTitle="Asp.Net
Radio Network" skinColor="5">
<song path="http://www.mydomain.com/mp3/song1.mp3" title="Song No. 1 " />
<song path="http://www.mydomain.com/mp3/song2.mp3" title="Song No. 2 " />
<song path="http://www.mydomain.com/mp3/song3.mp3" title="Song No. 3 " />
...what i need to do is have a .net script or function insert song titles into the url (whereas song1.mp3 would be a song title drawing from an sql database, along with a database field populating the title attribute in each record) . Any good sources on
how to do this?
Mar 17, 2011 04:54 PM|ASP.NET Dev|LINK
I would like to recommend simple xml serialization and de-serialization approach. In other words create a class “player” to represent root node “player” and create another class “song”. Add a property Songs (List<song>) in player class.
Populate the player class using xml de-serialization (i.e. read playlist xml file and populate “player” class), write code to add/remove/update “song” from List<song> collection. Serialize player class and save it as playlist.xml.
Make use of Custom Business Objects
Mar 20, 2011 10:54 PM|Decker Dong - MSFT|LINK
Hello! You can try this generic method with LINQ-TO-XML:))
static void AddNewMP3(string linkaddress, string name)
XDocument doc = XDocument.Load("XMLFile1.xml");
var root = doc.Root;
root.Add(new XElement("song", new XAttribute("path", linkaddress), new XAttribute("title", name)));
static void Main(string args)
AddNewMP3("http://newmp3.com.cn", "New MP3");
Apr 30, 2011 02:37 PM|Chumley Walrus|LINK
Hi I put this on the shelf for a little while, now i am back to developing this xml player again. I will test this out and perhaps post again if i have questions. Thanks Dong!