Exemple #1
0
bool RSS_PlaylistParser::Parse(std::string p_sContent)
{
		
	CXMLDocument* pDoc = new CXMLDocument();
	if(!pDoc->LoadFromString(p_sContent)) {
      // TODO Log the incorrect format
		delete pDoc;
		return false;
	}
	
	CXMLNode* pTmp;
	pTmp = pDoc->RootNode()->FindNodeByName("channel");
	if(!pTmp) {
      // TODO Log the incorrect format
		delete pDoc;
		return false;
	}
	
	for(int i = 0; i < pTmp->ChildCount(); i++) {
		if(pTmp->ChildNode(i)->Name().compare("item") != 0) {
      // TODO Log the incorrect format
			continue;
		}
		
		CXMLNode* pEnc = pTmp->ChildNode(i)->FindNodeByName("enclosure");
		if(!pEnc) {
      // TODO Log the incorrect format
			continue;
		}
		
		PlaylistEntry_t* pEntry = new PlaylistEntry_t();	
			
		pEntry->sFileName = pEnc->Attribute("url");
		pEntry->nSize = pEnc->AttributeAsUInt("length");
		pEntry->sMimeType = pEnc->Attribute("type");
		
		pEntry->bIsLocalFile = false;
			
		if(pTmp->ChildNode(i)->FindNodeByName("title")) {
			pEntry->sTitle = pTmp->ChildNode(i)->FindNodeByName("title")->Value();
		}
			
		m_lEntries.push_back(pEntry);
		
	}
		
/*		<channel>
	<title>Marillion Online Podcast</title>
	<link>http://www.marillion.com</link>
	<language>en</language>
	<copyright>&#x2117; &amp; &#xA9; 2006 Marillion</copyright>
	<pubDate>Wed, 13 Dec 2006 15:00:00 GMT</pubDate>
	<itunes:subtitle>Find a Better Way of Life at marillion.com</itunes:subtitle>
	<itunes:author>Marillion</itunes:author>
	<itunes:summary>Official insider information for British rock band Marillion. Whether writing in the studio, recording new material, preparing for a live show, or on the road - get the scoop DIRECT from the band members themselves. Find a Better Way of Life at marillion.com</itunes:summary>
	<description>Official insider information for British rock band Marillion. Whether writing in the studio, recording new material, preparing for a live show, or on the road - get the scoop DIRECT from the band members themselves. Find a Better Way of Life at marillion.com</description>
				
		
		<item>
		<title>Album Number 14 Begins</title>
		<itunes:author>Marillion</itunes:author>
		<itunes:subtitle>Recording is set to begin on the next studio album</itunes:subtitle>
		<itunes:summary>26 May 2006. Marillion have been jamming song ideas since the beginning of 2006 and have now come up with a short-list of contenders for the next studio album. Coming to you direct from the live room at the Racket Club studio with Mark Kelly, Ian Mosley, Pete Trewavas, Mike Hunter, and the Racket Records Peanut Gallery.</itunes:summary>
		<enclosure url="http://media.marillion.com/podcast/20060526.mp3" length="3361560" type="audio/mpeg" />
		<guid>http://media.marillion.com/podcast/20060526.mp3</guid>
		<pubDate>Fri, 26 May 2006 09:00:00 GMT</pubDate>
		<itunes:duration>4:00</itunes:duration>
		<itunes:explicit>yes</itunes:explicit>
		<itunes:keywords>marillion, studio, new, album, recording, update, racket, hogarth, kelly, mosley, trewavas, rothery</itunes:keywords>
	</item>	*/
		
	delete pDoc;
		
  if(!m_lEntries.empty()) {
    m_bEof = false;
    m_lEntriesIterator = m_lEntries.begin();
  }

	return true;
}