OnyxBlack
March 28th, 2009, 04:03 AM
this is what i have now... i know its like... completely wrong... but...
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNodeList items = doc.GetElementsByTagName("item");
foreach (XmlNode node in items)
{
string title = "", duration = "", description = "", date = "", thumbnail = "", url = "";
foreach (XmlNode child in node.ChildNodes)
{
switch (child.Name)
{
case "title":
title = child.InnerText;
break;
case "description":
description = child.InnerText;
break;
case "url":
XmlNode contentNode = null;
contentNode = node.Attributes("enclosure", doc.GetElementsByTagName("item"));
url = contentNode.Attributes["url"].Value;
break;
case "thumbnail":
thumbnail = child.InnerText;
break;
case "duration":
// required format is "H:MM:SS"
TimeSpan ts = TimeSpan.FromMilliseconds(double.Parse(child.InnerText));
duration = ts.Hours + ":" + ts.Minutes.ToString("D2") + ":" + ts.Seconds.ToString("D2");
break;
case "pubDate":
// required format is "2008-04-10T06:30:00"
date = DateTime.Parse(child.InnerText, System.Globalization.CultureInfo.InvariantCulture).ToString("s");
break;
}
}
and this is what i need to parse
<item>
<title>Love Bites - Sea of Love</title>
<itunes:author>Happy Tree Friends</itunes:author>
<description>If this boats a-rockin dont come a-knockin! Watch the second Love Bites short, Sea Of Love and prepare to fall in love all over again!</description>
<itunes:subtitle>If this boats a-rockin dont come a-knockin! Watch the second Love Bites short, Sea Of Love and prepare to fall in love all over again!</itunes:subtitle>
<itunes:summary>If this boats a-rockin dont come a-knockin! Watch the second Love Bites short, Sea Of Love and prepare to fall in love all over again!</itunes:summary>
<category>Comedy</category>
<itunes:keywords>Cartoons, Animation</itunes:keywords>
<itunes:image href="http://podcast.happytreefriends.com/htf.jpg"/>
<itunes:explicit>yes</itunes:explicit>
<enclosure url="http://media.libsyn.com/media/mondomedia/HTF_LB_SeaOfLove.m4v" length="7102660" type="video/mpeg"/>
<itunes:duration>1:30</itunes:duration>
<guid>http://media.libsyn.com/media/mondomedia/HTF_LB_SeaOfLove.m4v</guid>
<pubDate>Fri, 13 Feb 2009 12:00:00 -0800</pubDate>
</item>
basicly need the case "url" to equal the enclosure url also need the case "duration" to read the enclosure length... this is a bit over my head..
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNodeList items = doc.GetElementsByTagName("item");
foreach (XmlNode node in items)
{
string title = "", duration = "", description = "", date = "", thumbnail = "", url = "";
foreach (XmlNode child in node.ChildNodes)
{
switch (child.Name)
{
case "title":
title = child.InnerText;
break;
case "description":
description = child.InnerText;
break;
case "url":
XmlNode contentNode = null;
contentNode = node.Attributes("enclosure", doc.GetElementsByTagName("item"));
url = contentNode.Attributes["url"].Value;
break;
case "thumbnail":
thumbnail = child.InnerText;
break;
case "duration":
// required format is "H:MM:SS"
TimeSpan ts = TimeSpan.FromMilliseconds(double.Parse(child.InnerText));
duration = ts.Hours + ":" + ts.Minutes.ToString("D2") + ":" + ts.Seconds.ToString("D2");
break;
case "pubDate":
// required format is "2008-04-10T06:30:00"
date = DateTime.Parse(child.InnerText, System.Globalization.CultureInfo.InvariantCulture).ToString("s");
break;
}
}
and this is what i need to parse
<item>
<title>Love Bites - Sea of Love</title>
<itunes:author>Happy Tree Friends</itunes:author>
<description>If this boats a-rockin dont come a-knockin! Watch the second Love Bites short, Sea Of Love and prepare to fall in love all over again!</description>
<itunes:subtitle>If this boats a-rockin dont come a-knockin! Watch the second Love Bites short, Sea Of Love and prepare to fall in love all over again!</itunes:subtitle>
<itunes:summary>If this boats a-rockin dont come a-knockin! Watch the second Love Bites short, Sea Of Love and prepare to fall in love all over again!</itunes:summary>
<category>Comedy</category>
<itunes:keywords>Cartoons, Animation</itunes:keywords>
<itunes:image href="http://podcast.happytreefriends.com/htf.jpg"/>
<itunes:explicit>yes</itunes:explicit>
<enclosure url="http://media.libsyn.com/media/mondomedia/HTF_LB_SeaOfLove.m4v" length="7102660" type="video/mpeg"/>
<itunes:duration>1:30</itunes:duration>
<guid>http://media.libsyn.com/media/mondomedia/HTF_LB_SeaOfLove.m4v</guid>
<pubDate>Fri, 13 Feb 2009 12:00:00 -0800</pubDate>
</item>
basicly need the case "url" to equal the enclosure url also need the case "duration" to read the enclosure length... this is a bit over my head..