Example #1
0
bool WPL_PlaylistParser::Parse(std::string p_sContent)
{
	CXMLDocument* pDoc = new CXMLDocument();
	if(!pDoc->LoadFromString(p_sContent)) {
		delete pDoc;
		return false;
	}

  // Parse <head> data
  CXMLNode* pHead;
  pHead = pDoc->RootNode()->FindNodeByName("head");
  if (!pHead) {
    delete pDoc;
    return false;
  }
  
  // parse <body> data
  CXMLNode* pSeq;
  pSeq = pDoc->RootNode()->FindNodeByName("body");
  if (!pSeq) pSeq = pSeq->FindNodeByName("seq");
  if (!pSeq) {
    delete pDoc;
    return false;
  }
  
  int children = pSeq->ChildCount();
  CXMLNode* child;
  PlaylistEntry_t* pEntry;
  for (int i = 0; i < children; ++i) {
    child = pSeq->ChildNode(i);
		if(child->Name().compare("media") != 0) {
      continue;
    }
    
    pEntry = new PlaylistEntry_t();
    if(IsURL(child->Value())) {       
      pEntry->sFileName = child->Value();
      pEntry->bIsLocalFile = false;
    }
    else {
      pEntry->sFileName = FormatFileName(child->Value());
      pEntry->bIsLocalFile = true;
    }
    m_lEntries.push_back(pEntry);
  }

  if(!m_lEntries.empty()) {
    m_bEof = false;
    m_lEntriesIterator = m_lEntries.begin();
  }

  delete pDoc;
  return true;
}