本文整理汇总了C++中tinyxml2::XMLElement::Name方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::Name方法的具体用法?C++ XMLElement::Name怎么用?C++ XMLElement::Name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyxml2::XMLElement
的用法示例。
在下文中一共展示了XMLElement::Name方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecordedTV
bool GetObjectResponseSerializer::ItemXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
Item * item;
if (strcmp(element.Name(), "recorded_tv") == 0)
{
std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
std::string url = Util::GetXmlFirstChildElementText(&element, "url");
std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
int channelSubnumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
RECORDEDTV_STATE state = (RECORDEDTV_STATE) Util::GetXmlFirstChildElementTextAsInt(&element, "state");
item = new RecordedTV(objectId, parentId, url,thumbnail,channelName,canBeDeleted,size,creationTime,channelNumber,channelSubnumber, state);
tinyxml2::XMLElement * vElement = (tinyxml2::XMLElement*)(&element)->FirstChildElement("video_info");
VideoInfoSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, ((RecordedTV*) item)->VInfo);
m_items.push_back(item);
return false;
}
if (strcmp(element.Name(), "video") == 0)
{
std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
std::string url = Util::GetXmlFirstChildElementText(&element, "url");
std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
item = new Video(objectId, parentId, url,thumbnail,canBeDeleted,size,creationTime);
m_items.push_back(item);
return false;
}
if (strcmp(element.Name(), "audio") == 0)
{
item = new Audio();
m_items.push_back(item);
return false;
}
if (strcmp(element.Name(), "image") == 0)
{
item = new Image();
m_items.push_back(item);
return false;
}
return true;
}
示例2: strcmp
bool CStacksmithXMLPrinter::CompactMode( const tinyxml2::XMLElement& elem )
{
if( strcmp(elem.Name(),"text") == 0 || strcmp(elem.Name(),"script") == 0 || strcmp(elem.Name(),"td") == 0
|| strcmp(elem.Name(),"body") == 0 ) // For htmlText property.
return true;
const tinyxml2::XMLElement* firstElem = elem.FirstChildElement();
const tinyxml2::XMLNode* firstChild = elem.FirstChild();
if( firstChild && firstElem && firstChild == elem.LastChild() && firstElem == firstChild // Exactly one child, and it's an element?
&& firstElem->FirstChild() == NULL ) // And this element has no children? I.e. is self-closing?
{
return true;
}
return false;
}
示例3: ReadElement
/**
* Processes the current element within the context of the attributed object.
*/
bool XmlProcessor::ReadElement( Context & ctxt, const tinyxml2::XMLElement & elem, AccessorAdaptorBase* pAdaptor)
{
TranslatorId id = TE_END;
const char* szNodeName = elem.Name();
//Use the current translator if available to lookup appropriate
//translator for the current element. If not available,
//do a global search.
if( ctxt.pParent != NULL)
{
id = TranslatorIdFromElemName( szNodeName, ctxt.pParent->GetAllowedNodes() );
}
else //Do a global lookup.
{
for( int i = 0; i < COUNT_TRANSLATORS && id == TE_END; i++)
{
NodeEntry* pNodes = _Translators[i].translator.GetAllowedNodes();
if(pNodes == NULL) continue;
id = TranslatorIdFromElemName( szNodeName, pNodes);
}
}
//Get the translator and attempt to process the current
//element.
Translator& trans = TranslatorFromId( id);
return trans.OnRead( ctxt, elem, pAdaptor);
}
示例4: cf
bool ChannelFavoritesSerializer::GetFavoritesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
if (strcmp(element.Name(), "favorite") == 0)
{
std::string id = Util::GetXmlFirstChildElementText(&element, "id");
std::string name = Util::GetXmlFirstChildElementText(&element, "name");
//channels
ChannelFavorite::favorite_channel_list_t channels;
const tinyxml2::XMLElement* channels_element = element.FirstChildElement("channels");
if (channels_element != NULL)
{
const tinyxml2::XMLElement* channel_element = channels_element->FirstChildElement();
while (channel_element != NULL)
{
if (strcmp(channel_element->Name(), "channel") == 0)
{
if (channel_element->GetText() != NULL)
channels.push_back(channel_element->GetText());
}
channel_element = channel_element->NextSiblingElement();
}
}
ChannelFavorite cf(id, name, channels);
m_favoritesList.favorites_.push_back(cf);
return false;
}
return true;
}
示例5: Channel
bool GetChannelsResponseSerializer::GetChannelsResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
if (strcmp(element.Name(), "channel") == 0)
{
long channelDvbLinkId = Util::GetXmlFirstChildElementTextAsLong(&element, "channel_dvblink_id");
std::string channelId = Util::GetXmlFirstChildElementText(&element, "channel_id");
std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
int channelSubNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
Channel::DVBLinkChannelType channelType = (Channel::DVBLinkChannelType)Util::GetXmlFirstChildElementTextAsInt(&element, "channel_type");
std::string channelLogoUrl = Util::GetXmlFirstChildElementText(&element, "channel_logo");
Channel* channel = new Channel(channelId, channelDvbLinkId, channelName, channelType, channelLogoUrl, channelNumber, channelSubNumber);
if (m_parent.HasChildElement(*&element, "channel_child_lock"))
{
channel->ChildLock = Util::GetXmlFirstChildElementTextAsBoolean(&element, "channel_child_lock");
}
m_channelList.push_back(channel);
return false;
}
return true;
}
示例6: Program
bool GetSchedulesResponseSerializer::GetSchedulesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
if (strcmp(element.Name(), "schedule") == 0)
{
std::string scheduleId = Util::GetXmlFirstChildElementText(&element, "schedule_id");
std::string userParam = Util::GetXmlFirstChildElementText(&element, "user_param");
bool forceadd = Util::GetXmlFirstChildElementTextAsBoolean(&element, "force_add");
tinyxml2::XMLElement* epg = (tinyxml2::XMLElement*)(&element)->FirstChildElement("by_epg");
tinyxml2::XMLElement* manual = (tinyxml2::XMLElement*)(&element)->FirstChildElement("manual");
Schedule* s = NULL;
if (epg->FirstChildElement("program_id") != NULL) //byEPG
{
std::string channelid = Util::GetXmlFirstChildElementText(epg, "channel_id");
std::string programid = Util::GetXmlFirstChildElementText(epg, "program_id");
bool repeat = Util::GetXmlFirstChildElementTextAsBoolean(epg, "repeat");
bool newonly = Util::GetXmlFirstChildElementTextAsBoolean(epg, "new_only");
bool recordseriesanytime = Util::GetXmlFirstChildElementTextAsBoolean(epg, "record_series_anytime");
bool recordings_to_keep = Util::GetXmlFirstChildElementTextAsBoolean(epg, "recordings_to_keep");
tinyxml2::XMLElement* pEl = (tinyxml2::XMLElement*)(epg)->FirstChildElement("program");
Program* p = new Program();
ProgramSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *pEl, *p);
s = new Schedule(scheduleId,channelid,programid, p, recordings_to_keep,userParam,forceadd,repeat,newonly,recordings_to_keep);
}else{
std::string channelid = Util::GetXmlFirstChildElementText(epg, "channel_id");
std::string title = Util::GetXmlFirstChildElementText(epg, "title");
long starttime = Util::GetXmlFirstChildElementTextAsLong(epg, "start_time");
int duration = Util::GetXmlFirstChildElementTextAsLong(epg, "duration");
DayMask daymask = (DayMask)Util::GetXmlFirstChildElementTextAsInt(epg, "day_mask");
bool recordings_to_keep = Util::GetXmlFirstChildElementTextAsBoolean(epg, "recordings_to_keep");
s= new Schedule(scheduleId,channelid,title,starttime,duration,daymask,recordings_to_keep,userParam,forceadd);
}
if (s != NULL)
m_scheduleList.push_back(s);
return false;
}
return true;
}
示例7: Container
bool GetObjectResponseSerializer::ContainerXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
if (strcmp(element.Name(), "container") == 0)
{
std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
std::string name = Util::GetXmlFirstChildElementText(&element, "name");
std::string description = Util::GetXmlFirstChildElementText(&element, "description");
std::string logo = Util::GetXmlFirstChildElementText(&element, "logo");
dvblinkremote::CONTAINER_TYPE containerType = (dvblinkremote::CONTAINER_TYPE) Util::GetXmlFirstChildElementTextAsInt(&element, "container_type");
CONTENT_TYPE contentType = (CONTENT_TYPE) Util::GetXmlFirstChildElementTextAsInt(&element, "content_type");
int totalcount = Util::GetXmlFirstChildElementTextAsInt(&element, "total_count");
std::string sourceId = Util::GetXmlFirstChildElementText(&element, "source_id");
Container * container = new Container(objectId,parentId,name,description,logo,sourceId,containerType,contentType,totalcount);
m_containers.push_back(container);
return false;
}
return true;
}
示例8: ReadFirstElement
bool Translator::ReadFirstElement( const char* pszelem,
const tinyxml2::XMLElement& container,
bool bRequired, bool bDefault)
{
const XMLElement* pchild = container.FirstChildElement(pszelem);
if( pchild == NULL)
{
if( !bRequired)
return bDefault;
else
{
char buff[256];
sprintf( "Cannot find required boolean element %s in container %s", pszelem, container.Name());
throw TranslationException(buff);
}
}
else
{
return (strcmp( pchild->GetText(),"false")==0);
}
}
示例9: doc
/** sample ParaEngine mesh xml file
<mesh version=1 type=0>
<boundingbox minx=0 miny=0 minz=0 maxx=1 maxy=1 maxz=1/>
<shader index=3/>
<submesh loddist=10 filename="LOD_10.x"/>
<submesh loddist=50 filename="LOD_50.x"/>
</mesh>
*/
bool ParaEngine::CParaMeshXMLFile::LoadFromBuffer(const char* pData, int nSize)
{
#ifdef PARAENGINE_MOBILE
namespace TXML = tinyxml2;
try
{
TXML::XMLDocument doc(true, TXML::COLLAPSE_WHITESPACE);
doc.Parse(pData, nSize);
TXML::XMLElement* pRoot = doc.RootElement();
if (pRoot)
{
pRoot->QueryIntAttribute("version", &m_nVersion);
if (m_nVersion < SUPPORTED_MESH_FILE_VERSION)
{
OUTPUT_LOG("can not load para mesh xml file. because of a lower file version.\n");
}
int nType = 0;
pRoot->QueryIntAttribute("type", &nType);
m_nType = (ParaMeshXMLType)nType;
for (TXML::XMLNode* pChild = pRoot->FirstChild(); pChild != 0; pChild = pChild->NextSibling())
{
TXML::XMLElement* pElement = pChild->ToElement();
if (pElement)
{
std::string tagName = pElement->Name();
if (tagName == "boundingbox")
{
pElement->QueryFloatAttribute("minx", &m_vMinPos.x);
pElement->QueryFloatAttribute("miny", &m_vMinPos.y);
pElement->QueryFloatAttribute("minz", &m_vMinPos.z);
pElement->QueryFloatAttribute("maxx", &m_vMaxPos.x);
pElement->QueryFloatAttribute("maxy", &m_vMaxPos.y);
pElement->QueryFloatAttribute("maxz", &m_vMaxPos.z);
}
else if (tagName == "shader")
{
pElement->QueryIntAttribute("index", &m_nPrimaryShader);
// TODO: for shader parameters
for (TXML::XMLNode* pSubChild = pElement->FirstChild(); pSubChild != 0; pSubChild = pSubChild->NextSibling())
{
TXML::XMLElement* pParamElement = pSubChild->ToElement();
if (pParamElement)
{
std::string tagName = pParamElement->Name();
if (tagName == "params")
{
CParameter p;
// param name
p.SetName(pParamElement->Attribute("name", ""));
p.SetTypeByString(pParamElement->Attribute("type", ""));
p.SetValueByString(pParamElement->GetText());
m_paramBlock.AddParameter(p);
}
}
}
}
else if (tagName == "submesh")
{
CSubMesh meshInfo;
pElement->QueryFloatAttribute("loddist", &meshInfo.m_fToCameraDist);
std::string filepath = pElement->Attribute("filename");
// check if it is relative path or absolute path
if (filepath.find('/') != string::npos || filepath.find('\\') != string::npos)
meshInfo.m_sFileName = filepath;
else
meshInfo.m_sFileName = m_sParentDirectory + filepath;
m_SubMeshes.push_back(meshInfo);
}
}
}
}
}
catch (...)
{
OUTPUT_LOG("error parsing xml file %s**.xml \n", m_sParentDirectory.c_str());
return false;
}
return m_SubMeshes.size() > 0;
#else
TiXmlDocument doc;
try
{
doc.Parse(pData, 0, TIXML_DEFAULT_ENCODING);
TiXmlElement* pRoot = doc.RootElement();
{
// get mesh file version
TinyXPath::xpath_processor xpathProc(pRoot, "/mesh/@version");
TinyXPath::expression_result res = xpathProc.er_compute_xpath();
TinyXPath::node_set* pNodeSet = res.nsp_get_node_set();
if(pNodeSet!=0 && pNodeSet->u_get_nb_node_in_set()>0)
{
//.........这里部分代码省略.........
示例10: if
bool GetPlaybackObjectResponseSerializer::PlaybackItemXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
if (strcmp(element.Name(), "recorded_tv") == 0 ||
strcmp(element.Name(), "video") == 0)
{
PlaybackItem* item;
std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
std::string playbackUrl = Util::GetXmlFirstChildElementText(&element, "url");
std::string thumbnailUrl = Util::GetXmlFirstChildElementText(&element, "thumbnail");
if (strcmp(element.Name(), "recorded_tv") == 0)
{
tinyxml2::XMLElement* vElement = (tinyxml2::XMLElement*)element.FirstChildElement("video_info");
RecordedTvItemMetadata* metadata = new RecordedTvItemMetadata();
ItemMetadataSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, *metadata);
RecordedTvItem* recordedTvitem = new RecordedTvItem(objectId, parentId, playbackUrl, thumbnailUrl, metadata);
if (m_parent.HasChildElement(element, "channel_name"))
{
recordedTvitem->ChannelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
}
if (m_parent.HasChildElement(element, "channel_number"))
{
recordedTvitem->ChannelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
}
if (m_parent.HasChildElement(element, "channel_subnumber"))
{
recordedTvitem->ChannelSubNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
}
if (m_parent.HasChildElement(element, "state"))
{
recordedTvitem->State = (RecordedTvItem::DVBLinkRecordedTvItemState)Util::GetXmlFirstChildElementTextAsInt(&element, "state");
}
if (m_parent.HasChildElement(element, "schedule_id"))
{
recordedTvitem->ScheduleId = Util::GetXmlFirstChildElementText(&element, "schedule_id");
}
if (m_parent.HasChildElement(element, "schedule_name"))
{
recordedTvitem->ScheduleName = Util::GetXmlFirstChildElementText(&element, "schedule_name");
}
if (m_parent.HasChildElement(element, "schedule_series"))
{
recordedTvitem->SeriesSchedule = true;
}
item = (PlaybackItem*)recordedTvitem;
}
else if (strcmp(element.Name(), "video") == 0)
{
tinyxml2::XMLElement* vElement = (tinyxml2::XMLElement*)element.FirstChildElement("video_info");
VideoItemMetadata* metadata = new VideoItemMetadata();
ItemMetadataSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, *metadata);
VideoItem* videoItem = new VideoItem(objectId, parentId, playbackUrl, thumbnailUrl, metadata);
item = (PlaybackItem*)videoItem;
}
if (item)
{
if (m_parent.HasChildElement(element, "can_be_deleted"))
{
item->CanBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
}
if (m_parent.HasChildElement(element, "size"))
{
item->Size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
}
if (m_parent.HasChildElement(element, "creation_time"))
{
item->CreationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
}
m_playbackItemList.push_back(item);
}
return false;
}
return true;
}