本文整理汇总了C++中TiXmlNode::ToElement方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::ToElement方法的具体用法?C++ TiXmlNode::ToElement怎么用?C++ TiXmlNode::ToElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::ToElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: treatOneLanguage
/** Get all the language nodes and call TreatOneLanguage for each one
*
*/
void RainbruRPG::Options::xmlLanguage::treatAllLanguages(){
TiXmlNode* childNode = root->FirstChild( "Language" );
if (childNode){
TiXmlElement* child= childNode->ToElement();
for( child; child; child=child->NextSiblingElement() ){
treatOneLanguage(child);
}
}
else{
LOGW(_("Empty language list found"));
}
}
示例2: LoadSounds
void zzzSndSystem::LoadSounds()
{
//read xml & load sets
DataStreamPtr data = ResourceGroupManager::getSingleton().openResource("sounds.xml");
String str = data->getAsString();
TiXmlDocument doc;
doc.Parse(str.c_str());
if (!doc.Error())
{
TiXmlNode* node;
node=doc.FirstChild();
node=node->FirstChild();
for (;node!=0;node=node->NextSibling())
{
if (node->Type() == TiXmlNode::ELEMENT)
{
//get params
String name = "";
String file = "";
if (strcmp(node->Value(), "sound") == 0)
{
TiXmlAttribute* att = node->ToElement()->FirstAttribute();
while (att)
{
if (strcmp(att->Name(), "name") == 0)
{
name = att->Value();
}
else if (strcmp(att->Name(), "file") == 0)
{
file = att->Value();
}
att = att->Next();
}
if (name.length() > 0)
{
SND->LoadSound(name, file);
}
}
}
}
}
else
{
throw Exception(Exception::ERR_FILE_NOT_FOUND, std::string(doc.ErrorDesc()) + " : particles.xml", __FUNCTION__);
}
}
示例3: 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");
}
示例4: LoadAlgorithmSettings
/**
Wczytuje atrybuty algorytmu.
Wczytana zostaje miedzy innymi nazwa alogrytmu.
@param algo Wskaznik do konfigurowanego algorytmu
*/
void XMLConfigFile::LoadAlgorithmSettings(Algorithm* algo) {
TRACE( "XMLConfigFile::LoadAlgorithmSettings - Wczytywanie ustawien algorytmu...\n" );
TiXmlElement* algoXmlElem;
TiXmlNode* algoXmlNode;
string algoName;
TiXmlHandle docHandle( &document );
algoXmlNode = docHandle.FirstChild( "algorithm" ).Node();
if(algoXmlElem != NULL) {
algoXmlElem = algoXmlNode->ToElement();
if( algoXmlElem->Attribute("name") )
algo->SetName( algoXmlElem->Attribute("name") );
}
}
示例5: StreamIn
void TiXmlDocument::StreamIn(std::istream * in, TIXML_STRING * tag) {
// The basic issue with a document is that we don't know what we're
// streaming. Read something presumed to be a tag (and hope), then
// identify it, and call the appropriate stream method on the tag.
//
// This "pre-streaming" will never read the closing ">" so the
// sub-tag can orient itself.
if (!StreamTo(in, '<', tag)) {
SetError(TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
while (in->good()) {
int tagIndex = (int) tag->length();
while (in->good() && in->peek() != '>') {
int c = in->get();
if (c <= 0) {
SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
break;
}
(*tag) += (char) c;
}
if (in->good()) {
// We now have something we presume to be a node of
// some sort. Identify it, and call the node to
// continue streaming.
TiXmlNode* node = Identify(tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING);
if (node) {
node->StreamIn(in, tag);
bool isElement = node->ToElement() != 0;
delete node;
node = 0;
// If this is the root element, we're done. Parsing will be
// done by the >> operator.
if (isElement) {
return;
}
} else {
SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
}
}
// We should have returned sooner.
SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
}
示例6: doc
const String& MimeType::comment(void) {
// calling without mime loaded do nothing
if(!(status & MIME_LOADED))
return mcmt;
if(status & COMMENT_LOADED)
return mcmt;
String ttype = mtype;
ttype += ".xml";
const char* p = xdg_mime_find_data(ttype.c_str());
if(!p)
return mcmt;
String path = p;
TiXmlDocument doc(path.c_str());
if(!doc.LoadFile()) {
E_DEBUG(E_STRLOC ": MimeType::comment() %s malformed\n", path.c_str());
return mcmt;
}
TiXmlNode* el = doc.FirstChild("mime-type");
/*
* First element which does not have "xml:lang" attribute
* is default one. So hunt that one :)
*
* Btw. TinyXML does not handle XML namespaces and will return
* "<namespace>:<attribute>" value. This is not big deal as long
* as correctly fetch attribute values.
*/
for(el = el->FirstChildElement(); el; el = el->NextSibling()) {
if(strncmp(el->Value(), "comment", 7) == 0) {
// TODO: add locale here
if(!el->ToElement()->Attribute("xml:lang")) {
TiXmlText* data = el->FirstChild()->ToText();
if(data) {
mcmt = data->Value();
break;
}
}
}
}
status |= COMMENT_LOADED;
return mcmt;
}
示例7: TiXmlFindElement
TiXmlElement* TiXmlFindElement(TiXmlDocument* doc, const xdl_char* elements) {
std::vector<std::string> tokens;
size_t number = xstd::tokenize(elements, tokens, "/");
TiXmlNode* child = doc;
size_t count = 0;
while(count < number) {
child = child->FirstChild(tokens[count].c_str());
count++;;
}
if(child != NULL)
return child->ToElement();
return NULL;
}
示例8: StreamOut
void TiXmlDocument::StreamOut( TIXML_OSTREAM * out ) const
{
TiXmlNode* node;
for ( node=FirstChild(); node; node=node->NextSibling() )
{
node->StreamOut( out );
// Special rule for streams: stop after the root element.
// The stream in code will only read one element, so don't
// write more than one.
if ( node->ToElement() )
break;
}
}
示例9: treatCountry
/** Treat all countries of a single language
*
*/
void RainbruRPG::Options::xmlLanguage::
treatLanguageCountries(TiXmlElement* e, const LanguageListItem& it){
TiXmlNode* childNode = e->FirstChild( "Country" );
if (childNode){
TiXmlElement* child= childNode->ToElement();
for( child; child; child=child->NextSiblingElement() ){
treatCountry(child, it);
}
}
else{
LOGW(_("Empty country list found"));
}
}
示例10: Get
const char* CXmlSiblingElemIter::Get(const char* szElemName)const
{
const char* szText=NULL;
if (m_pCurNode)
{
TiXmlNode* pNode = m_pCurNode->FirstChildElement( szElemName );
if (pNode)
{
szText = pNode->ToElement()->GetText();
}
}
return szText;
}
示例11: FindLNType
int CXGseScd::FindLNType(TiXmlNode *pLN0Node, const std::string &prefix, const std::string &ln_class, const std::string &ln_inst, const std::string &do_name, std::string &ds_desc, std::string &ln_type)
{
TiXmlNode *pXmlLNNode = pLN0Node->NextSibling("LN");
TiXmlElement *pLNElement = NULL;
while (pXmlLNNode != NULL)
{
pLNElement = pXmlLNNode->ToElement();
if ((ln_class == pLNElement->Attribute("lnClass"))
&& (ln_inst == pLNElement->Attribute("inst"))
&& ((prefix == "")
|| (prefix == pLNElement->Attribute("prefix"))))
{
ln_type = pLNElement->Attribute("lnType");
TiXmlNode *pDONode = pXmlLNNode->FirstChild("DOI");
while (pDONode != NULL)
{
if (pDONode->ToElement()->Attribute("name") == do_name)
{
TiXmlNode *pDANode = pDONode->FirstChild("DAI");
while (pDANode != NULL)
{
if (pDANode->ToElement()->Attribute("name") == std::string("dU"))
{
ds_desc = pDANode->FirstChildElement("Val")->GetText();
break;
}
pDANode = pDANode->NextSibling();
}
return J_OK;
}
pDONode = pDONode->NextSibling();
}
}
pXmlLNNode = pXmlLNNode->NextSibling("LN");
}
return J_NOT_FOUND;
}
示例12: save_game
void GameIntro::save_game(std::string & filename){
// vytvorit dokument
TiXmlDocument doc;
doc.InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
// element game
TiXmlNode *node;
TiXmlElement *el, *rootEl;
node = doc.InsertEndChild(TiXmlElement("game"));
if(!node)
TiXmlError("can't create root element");
rootEl = node->ToElement();
rootEl->SetAttribute("episode", cur_episode_);
rootEl->SetAttribute("level", cur_level_);
// elementy hracu
std::string el_name;
PlayerProperties prop;
for(Uint16 i = 0 ; i < players_count_ ; ++i){
el_name = "player"+x2string(i);
node = rootEl->InsertEndChild(TiXmlElement(el_name.c_str()));
if(!node)
TiXmlError("can't create element "+el_name);
el = node->ToElement();
// atributy
gameBase_->get_player(i, prop);
el->SetAttribute("lives", prop.lives);
el->SetAttribute("flames", prop.flames);
el->SetAttribute("bombs", prop.bombs);
el->SetAttribute("boots", prop.boots);
}
// ulozit do souboru
try {
TiXmlSaveDocument(doc, filename);
}
catch(const std::string & err){
TiXmlError(filename, err);
}
}
示例13: parseImpl
void BulletMLParserTinyXML::parseImpl(TiXmlDocument& doc) {
if (doc.Error()) {
#ifdef __EXCEPTIONS
throw BulletMLError(doc.Value() + ": " + doc.ErrorDesc());
#endif
}
TiXmlNode* node;
for (node = doc.FirstChild(); node; node = node->NextSibling()) {
if (node->ToElement() != 0) {
getTree(node);
break;
}
}
}
示例14: loadConfig
void Config::loadConfig(String configNamespace, String fileName) {
TiXmlDocument doc(fileName.c_str());
Logger::log("Loading config: %s\n", fileName.c_str());
if(!doc.LoadFile()) {
Logger::log("Error loading config file...\n");
Logger::log("Error: %s\n", doc.ErrorDesc());
return;
}
TiXmlElement *rootElement = doc.RootElement();
TiXmlNode *pChild;
ConfigEntry *entry;
for(pChild = rootElement->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
entry = getEntry(configNamespace, pChild->Value());
entry->stringVal = pChild->ToElement()->GetText();
entry->numVal = atof(pChild->ToElement()->GetText());
entry->isString = true;
entry->configNamespace = configNamespace;
}
}
示例15: LoadRects
/*
функция считывает прямоугольники из файла out_r.xml
в массив g_rects
*/
void LoadRects(int w, int h)
{
TiXmlDocument doc("out_r.xml");
if (!doc.LoadFile())
return;
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem = NULL;
TiXmlHandle hRoot(0);
pElem = hDoc.FirstChildElement().Element();
if (pElem == NULL)
return;
if (strcmp(pElem->Value(), "Rects") != 0)
return;
int count = 0;
double v = 0;
for (TiXmlNode* child = pElem->FirstChild(); child; child = child->NextSibling())
{
if (strcmp(child->Value(), "rect") != 0)
continue;
child->ToElement()->QueryDoubleAttribute("x",&v);
g_rects[count].x = (int)(w*v/100.);
child->ToElement()->QueryDoubleAttribute("y",&v);
g_rects[count].y = (int)(h*v/100.);
child->ToElement()->QueryDoubleAttribute("w",&v);
g_rects[count].width = (int)(w*v/100.);
child->ToElement()->QueryDoubleAttribute("h",&v);
g_rects[count].height = (int)(h*v/100.);
count++;
if (count > C_MAX_OBJECTS)
break;
}
g_rects_count = count;
MakeMaskImage(g_mask);
}