本文整理汇总了C++中TiXmlNode::ValueStr方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::ValueStr方法的具体用法?C++ TiXmlNode::ValueStr怎么用?C++ TiXmlNode::ValueStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::ValueStr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
MSBInfoPage* MSBInfo::Parse(TiXmlNode* page)
{
if (page)
{
_page = new MSBInfoPage();
TiXmlNode* child = 0;
TiXmlNode* root = page;
TiXmlElement* pageElement = page->ToElement();
if (pageElement)
{
_page->EID = pageElement->Attribute("eid");
_page->Category = pageElement->Attribute("category");
_page->Type = pageElement->Attribute("type");
_page->NodeName = pageElement->Attribute("nodeName");
TiXmlNode* title = page->FirstChild("title");
if (title)
_page->Title = title->ToElement()->GetText();
else
Core::Dbg->Log(Warning, "No title node found");
}
else
Core::Dbg->Log(Warning, "Page node not accessible");
pageElement = 0;
// Navigate to the 'background' part while adding skills
while((child = root->IterateChildren(child)))
{
if (child->ValueStr().compare("skill") == 0)
{
TiXmlElement* skillelement = child->ToElement();
if (skillelement)
{
Skill* sk = new Skill();
sk->ID = skillelement->Attribute("kid");
sk->Name = skillelement->GetText();
_page->Skills.push_back(sk);
}
else
Core::Dbg->Log(Warning, "Conversion error in Skill node");
}
if (child->ValueStr().compare("backgroundInfo") == 0)
{
// Handle background node
XMLProcessBackground(child);
}
}
}
else
Core::Dbg->Log(Warning, "XML parse error, no page element found");
return _page;
}
示例2: Load
bool CSmartPlaylistRule::Load(TiXmlElement *element, const CStdString &encoding /* = "UTF-8" */)
{
if (element == NULL)
return false;
// format is:
// <rule field="Genre" operator="contains">parameter</rule>
// where parameter can either be a string or a list of
// <value> tags containing a string
const char *field = element->Attribute("field");
const char *oper = element->Attribute("operator");
TiXmlNode *parameter = element->FirstChild();
if (field == NULL || oper == NULL || parameter == NULL)
return false;
if (parameter->Type() == TiXmlNode::TINYXML_TEXT)
{
CStdString utf8Parameter;
if (encoding.IsEmpty()) // utf8
utf8Parameter = parameter->ValueStr();
else
g_charsetConverter.stringCharsetToUtf8(encoding, parameter->ValueStr(), utf8Parameter);
if (!utf8Parameter.empty())
m_parameter.push_back(utf8Parameter);
}
else if (parameter->Type() == TiXmlNode::TINYXML_ELEMENT)
{
TiXmlElement *valueElem = element->FirstChildElement("value");
while (valueElem != NULL)
{
TiXmlNode *value = valueElem->FirstChild();
if (value != NULL && value->Type() == TiXmlNode::TINYXML_TEXT)
{
CStdString utf8Parameter;
if (encoding.IsEmpty()) // utf8
utf8Parameter = value->ValueStr();
else
g_charsetConverter.stringCharsetToUtf8(encoding, value->ValueStr(), utf8Parameter);
if (!utf8Parameter.empty())
m_parameter.push_back(utf8Parameter);
}
valueElem = valueElem->NextSiblingElement("value");
}
}
else
return false;
m_field = TranslateField(field);
m_operator = TranslateOperator(oper);
return true;
}
示例3: Parse
bool BXBoxeeServices::Parse()
{
TiXmlHandle docHandle(&m_doc);
TiXmlNode* pTSChild = docHandle.FirstChild("services").FirstChild("timestamp").FirstChild().Node();
if (pTSChild)
{
m_timestamp = atoi(pTSChild->Value());
}
TiXmlElement *pChild = docHandle.FirstChild("services").Element();
if (!pChild)
{
LOG(LOG_LEVEL_ERROR,"BXBoxeeServices::Parse - FAILED to find <applications> node");
return false;
}
m_services.clear();
TiXmlNode *pMsgNode = 0;
while ((pMsgNode = pChild->IterateChildren(pMsgNode)) != NULL)
{
if (pMsgNode->ValueStr().compare("object") == 0)
{
BXObject obj;
if (obj.FromXML(pMsgNode))
{
m_services.push_back(obj);
}
}
}
return true;
}
示例4: LoadAlbumsInfo
bool CMetadataResolverMusic::LoadAlbumsInfo(BOXEE::BXXMLDocument& doc, vectorMetadata& list)
{
TiXmlElement* pRootElement = doc.GetDocument().RootElement();
bool bRetVal = true;
if (pRootElement->ValueStr() == "results")
{
TiXmlNode* pTag = 0;
BXMetadata album(MEDIA_ITEM_TYPE_AUDIO);
while ((pTag = pRootElement->IterateChildren(pTag)))
{
if (pTag && pTag->ValueStr() == "album")
{
TiXmlElement* pValue = pTag->FirstChildElement();
if (pValue && (LoadAlbumInfo(pValue,album)))
list.push_back(album);
else
bRetVal = false;
}
else
bRetVal = false;
}
}
else
bRetVal = false;
return bRetVal;
}
示例5: ParseBiLink
//<BiLink>
void LibraryParser::ParseBiLink(TiXmlNode* pParent) {
GetBiLinkAttributes(pParent ) ;
TiXmlNode* Child;
string Elem;
BiLink L;
int Lcount = 0;
for (Child = pParent->FirstChild() ; Child != 0; Child
= Child->NextSibling() ) {
Elem = Child->ValueStr() ;
if (Elem == "Link") {
ParseLink(Child ) ;
if (Lcount == 0) {
L.L1(mCurrentLink) ;
Lcount++;
} else if (Lcount==1) {
L.L2(mCurrentLink) ;
}
} else {
cout << "Unknown XML element "<< Elem << " in file "<< mFname
<< endl ;
}
}
mCurrentBiLink = L ;
mLib->AddBiLink(mCurrentBiLink) ;
}
示例6: Parse
bool BXBoxeeWebFavorites::Parse()
{
TiXmlHandle docHandle(&m_doc);
TiXmlElement *pChild = docHandle.FirstChild("bookmarks").Element();
if (!pChild)
{
LOG(LOG_LEVEL_ERROR,"BXBoxeeWebFavorites::Parse - FAILED to find <bookmark> node");
return false;
}
m_webFavorites.clear();
TiXmlNode *pMsgNode = 0;
while ((pMsgNode = pChild->IterateChildren(pMsgNode)) != NULL)
{
if (pMsgNode->ValueStr().compare("bookmark") == 0)
{
BXObject obj;
if (obj.FromXML(pMsgNode))
{
m_webFavorites.push_back(obj);
}
}
}
return true;
}
示例7: ResolveParametersForNode
void CGUIIncludes::ResolveParametersForNode(TiXmlElement *node, const Params& params)
{
if (!node)
return;
std::string newValue;
// run through this element's attributes, resolving any parameters
TiXmlAttribute *attribute = node->FirstAttribute();
while (attribute)
{
ResolveParamsResult result = ResolveParameters(attribute->ValueStr(), newValue, params);
if (result == SINGLE_UNDEFINED_PARAM_RESOLVED && strcmp(node->Value(), "param") == 0 &&
strcmp(attribute->Name(), "value") == 0 && node->Parent() && strcmp(node->Parent()->Value(), "include") == 0)
{
// special case: passing <param name="someName" value="$PARAM[undefinedParam]" /> to the nested include
// this usually happens when trying to forward a missing parameter from the enclosing include to the nested include
// problem: since 'undefinedParam' is not defined, it expands to <param name="someName" value="" /> and overrides any default value set with <param name="someName" default="someValue" /> in the nested include
// to prevent this, we'll completely remove this parameter from the nested include call so that the default value can be correctly picked up later
node->Parent()->RemoveChild(node);
return;
}
else if (result != NO_PARAMS_FOUND)
attribute->SetValue(newValue);
attribute = attribute->Next();
}
// run through this element's value and children, resolving any parameters
TiXmlNode *child = node->FirstChild();
if (child)
{
if (child->Type() == TiXmlNode::TINYXML_TEXT)
{
ResolveParamsResult result = ResolveParameters(child->ValueStr(), newValue, params);
if (result == SINGLE_UNDEFINED_PARAM_RESOLVED && strcmp(node->Value(), "param") == 0 &&
node->Parent() && strcmp(node->Parent()->Value(), "include") == 0)
{
// special case: passing <param name="someName">$PARAM[undefinedParam]</param> to the nested include
// we'll remove the offending param tag same as above
node->Parent()->RemoveChild(node);
}
else if (result != NO_PARAMS_FOUND)
child->SetValue(newValue);
}
else if (child->Type() == TiXmlNode::TINYXML_ELEMENT)
{
do
{
TiXmlElement *next = child->NextSiblingElement(); // save next as current child might be removed from the tree
ResolveParametersForNode(static_cast<TiXmlElement *>(child), params);
child = next;
}
while (child);
}
}
}
示例8: XMLProcessBackground
void MSBInfo::XMLProcessBackground(TiXmlNode* bg)
{
if (bg)
{
TiXmlNode* child = 0;
_page->Text = "";
while((child = bg->IterateChildren(child)))
{
if (child->ValueStr().compare("avobject") == 0)
{
TiXmlElement* av = child->ToElement();
_page->Image = av->Attribute("filename");
}
if (child->ValueStr().compare("txt") == 0)
{
TiXmlElement* txt = child->ToElement();
_page->Text += txt->GetText();
}
}
}
else
Core::Dbg->Log(Warning, "NULL value passed to utterance node handler");
}
示例9: while
void
XmlPrototypesFile::LoadPrototypes()
{
TiXmlNode* node = m_File.RootElement();
if( node == NULL || node->ValueStr() != "prototypes" )
{
LOG_ERROR( "UI Manager: " + m_File.ValueStr() + " is not a valid prototypes file! No <prototypes> in root." );
return;
}
node = node->FirstChild();
while( node != NULL )
{
if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "prototype" )
{
Ogre::String name = GetString( node, "name" );
UiManager::getSingleton().AddPrototype( name, node->Clone() );
}
node = node->NextSibling();
}
}
示例10: ParseInterface
//<Interface>
void LibraryParser::ParseInterface(TiXmlNode* pParent) {
GetInterfaceAttributes(pParent ) ;
TiXmlNode* Child;
string Elem;
for (Child = pParent->FirstChild() ; Child != 0; Child
= Child->NextSibling() ) {
Elem = Child->ValueStr() ;
if (Elem == "") {
Parse(Child ) ;
} else {
cout << "Unknown XML element "<< Elem << " in file "<< mFname
<< endl ;
}
}
}
示例11: GetString
const Ogre::String
XmlMapFile::GetWalkmeshFileName()
{
TiXmlNode* node = m_File.RootElement();
if( node == NULL || node->ValueStr() != "map" )
{
LOG_ERROR( "Field Map XML Manager: " + m_File.ValueStr() + " is not a valid fields map file! No <map> in root." );
return "";
}
node = node->FirstChild();
while( node != NULL )
{
if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "walkmesh" )
{
return GetString( node, "file_name" );
}
node = node->NextSibling();
}
LOG_WARNING( "Can't find field's walkmesh in " + m_File.ValueStr() + "." );
return "";
}
示例12: ParseLibrary
//<Library>
void LibraryParser::ParseLibrary(TiXmlNode* pParent) {
cerr << "Parsing the Library "<< endl ;
GetLibraryAttributes(pParent ) ;
TiXmlNode* Child;
string Elem;
for (Child = pParent->FirstChild() ; Child != 0; Child
= Child->NextSibling() ) {
Elem = Child->ValueStr() ;
if (Elem == "Node") {
ParseNode(Child ) ;
} else if (Elem == "Link") {
ParseLink(Child ) ;
} else if (Elem == "BiLink") {
ParseBiLink(Child ) ;
} else {
cout << "Unknown XML element "<< Elem<< " in file "<< mFname<< endl ;
}
}
}
示例13: ParseLink
//<Link>
void LibraryParser::ParseLink(TiXmlNode* pParent) {
GetLinkAttributes(pParent ) ;
TiXmlNode* Child;
string Elem;
for (Child = pParent->FirstChild() ; Child != 0; Child
= Child->NextSibling() ) {
Elem = Child->ValueStr() ;
if (Elem == "Source") {
ParseLinkSource(Child ) ;
} else if (Elem == "Dest") {
ParseLinkDest(Child ) ;
} else {
cout << "Unknown XML element "<< Elem << " in file "<< mFname
<< endl ;
}
}
//Add link to the library
mLib->AddLink(mCurrentLink) ;
}
示例14: ParseDocument
void LibraryParser::ParseDocument(TiXmlNode* pParent) {
if ( !pParent )
return;
int Type = pParent->Type() ;
string Elem;
if (Type == TiXmlNode::DOCUMENT ) {
cout << "Parsing the library from file "<< mFname << endl ;
TiXmlNode* Child;
for (Child = pParent->FirstChild() ; Child != 0; Child
= Child->NextSibling() ) {
Elem = Child->ValueStr() ;
if (Elem == "Library")
ParseLibrary(Child ) ;
}
} else {
cout << "The document should be parsed..."<< endl ;
}
return;
}
示例15: Test
bool CXBMCTinyXML::Test()
{
// scraper results with unescaped &
CXBMCTinyXML doc;
CStdString data("<details><url function=\"ParseTMDBRating\" "
"cache=\"tmdb-en-12244.json\">"
"http://api.themoviedb.org/3/movie/12244"
"?api_key=57983e31fb435df4df77afb854740ea9"
"&language=en???</url></details>");
doc.Parse(data.c_str());
TiXmlNode *root = doc.RootElement();
if (root && root->ValueStr() == "details")
{
TiXmlElement *url = root->FirstChildElement("url");
if (url && url->FirstChild())
{
return (url->FirstChild()->ValueStr() == "http://api.themoviedb.org/3/movie/12244?api_key=57983e31fb435df4df77afb854740ea9&language=en???");
}
}
return false;
}