This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
/
GetChannelListResult.cpp
53 lines (45 loc) · 1.7 KB
/
GetChannelListResult.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "GetChannelListResult.h"
#include <stdlib.h>
#include "tinyXML/tinyxml.h"
#include "utils/log.h"
GetChannelListResult::GetChannelListResult() {
}
GetChannelListResult::~GetChannelListResult() {
}
void GetChannelListResult::parseData(const CStdString& xmlData) {
TiXmlDocument xml;
xml.Parse(xmlData.c_str(), 0, TIXML_ENCODING_LEGACY);
TiXmlElement* rootXmlNode = xml.RootElement();
if (!rootXmlNode) {
errors_.push_back(" No root node parsed");
CLog::Log(LOGDEBUG, "MythXML GetChannelListResult - No root node parsed");
return;
}
TiXmlElement* programGuideResponseNode = NULL;
CStdString strValue = rootXmlNode->Value();
if (strValue.Find("GetProgramGuideResponse") >= 0 ) {
programGuideResponseNode = rootXmlNode;
}
else if (strValue.Find("detail") >= 0 ) {
// process the error.
TiXmlElement* errorCodeXmlNode = rootXmlNode->FirstChildElement("errorCode");
TiXmlElement* errorDescXmlNode = rootXmlNode->FirstChildElement("errorDescription");
CStdString error;
error.Format("ErrorCode [%i] - %s", errorCodeXmlNode->GetText(), errorDescXmlNode->GetText());
errors_.push_back(error);
return;
}
else
return;
TiXmlElement* programGuideNode = programGuideResponseNode->FirstChildElement("ProgramGuide");
TiXmlElement* channelsNode = programGuideNode->FirstChildElement("Channels");
TiXmlElement* child = NULL;
for( child = channelsNode->FirstChildElement("Channel"); child; child = child->NextSiblingElement("Channel")){
SChannel channel;
channel.id = atoi(child->Attribute("chanId"));
channel.name = child->Attribute("channelName");
channel.callsign = child->Attribute("callSign");
channel.number = child->Attribute("chanNum");
channels_.push_back(channel);
}
}