当前位置: 首页>>代码示例>>C++>>正文


C++ XMLDocument::FirstChildElement方法代码示例

本文整理汇总了C++中XMLDocument::FirstChildElement方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLDocument::FirstChildElement方法的具体用法?C++ XMLDocument::FirstChildElement怎么用?C++ XMLDocument::FirstChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLDocument的用法示例。


在下文中一共展示了XMLDocument::FirstChildElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rss_feed_parse

void rss_feed_parse(const std::string &feed)
{
    XMLDocument doc;
    doc.Parse(feed.c_str());
    XMLElement *rss = doc.FirstChildElement("rss");
    if (rss) {
        XMLElement *channel = rss->FirstChildElement("channel");
        if (channel) {
            for (XMLElement *article = channel->FirstChildElement("item"); article; article = article->NextSiblingElement("item")) {
                XMLElement *title = article->FirstChildElement("title"); 
                XMLElement *link = article->FirstChildElement("link"); 
                std::cout << title->GetText() << std::endl;
                std::cout << link->GetText() << std::endl;
                std::cout << std::endl;
            }
        }
    }
}
开发者ID:rohshall,项目名称:hnews,代码行数:18,代码来源:hnews.cpp

示例2: readSpecs

int SPECAPIENTRY readSpecs(const char* xmlData, unsigned int bytes,
    Function** functions, unsigned int* functionCount,
    Constant** constants, unsigned int* constantsCount)
{
    XMLDocument document;
    if (document.Parse(xmlData, bytes) == XMLError::XML_NO_ERROR)
    {
        XMLElement* registry = document.FirstChildElement("registry");
        if (registry)
        {
            ObtainConstants(registry, constantsCount, constants);
            ObtainCommands(registry, functionCount, functions);
            ObtainFeatures(registry, functionCount, functions);
            ObtainExtensions(registry, functionCount, functions);
        }
    }
    return 0;
}
开发者ID:tak2004,项目名称:OpenGLVM,代码行数:18,代码来源:libSpec.cpp

示例3: loadMap

bool TiledMap::loadMap(string source)
{
    XMLDocument map;
    map.LoadFile(source.data());

    XMLElement* map_info =  map.FirstChildElement("map");

    this->version = map_info->Attribute("version");
    this->orientation = map_info->Attribute("orientation");

    this->width = this->stringToInt(map_info->Attribute("width"));
    this->height = this->stringToInt(map_info->Attribute("height"));
    this->tilewidth = this->stringToInt(map_info->Attribute("tilewidth"));
    this->tileheight = this->stringToInt(map_info->Attribute("tileheight"));

    this->loadTilesets(&map);
    this->loadLayers(&map);
    this->loadObjectGroups(&map);
}
开发者ID:corcrash,项目名称:Tiled-Map-Parser,代码行数:19,代码来源:tiledmap.cpp

示例4: loadModels

void Scene::loadModels(XMLDocument& doc){

	// Load all models paths
	XMLElement *models = doc.FirstChildElement("scene")->FirstChildElement("models");
    
	for (const XMLElement* model = models->FirstChildElement(); model != NULL; model = model->NextSiblingElement())
	{
        
        string path = model->FirstChildElement("path")->GetText();
        // Translate
        glm::vec3 translate =  glm::vec3(model->FirstChildElement("translate")->FindAttribute("x")->FloatValue(),
                                         model->FirstChildElement("translate")->FindAttribute("y")->FloatValue(),
                                         model->FirstChildElement("translate")->FindAttribute("z")->FloatValue());
        // Scale
        glm::vec3 scale =  glm::vec3(model->FirstChildElement("scale")->FindAttribute("x")->FloatValue(),
                                     model->FirstChildElement("scale")->FindAttribute("y")->FloatValue(),
                                     model->FirstChildElement("scale")->FindAttribute("z")->FloatValue());

        // Rotate
        glm::vec3 rotate;
        float rotateAngle;
        // Only if a rotate parameter is set in the XML
        if (model->FirstChildElement("rotate"))
        {
            rotate =  glm::vec3(model->FirstChildElement("rotate")->FindAttribute("x")->FloatValue(),
                                       model->FirstChildElement("rotate")->FindAttribute("y")->FloatValue(),
                                       model->FirstChildElement("rotate")->FindAttribute("z")->FloatValue());
            
            rotateAngle = atof(model->FirstChildElement("rotate")->GetText());
        } else {
            rotate = glm::vec3(0.0, 0.0, 0.0);
            rotateAngle = 0;
        }

        int interactionDialogue = -1; //Default state no interaction possible
        if(model->FirstChildElement("interaction")){
            interactionDialogue = atoi(model->FirstChildElement("interaction")->GetText());
        }

        _models.push_back(Model(path, translate, scale, rotate, rotateAngle, interactionDialogue));
	}
}
开发者ID:Olivier-Daire,项目名称:La-broloc,代码行数:42,代码来源:scene.cpp

示例5: current

set<string> compareWithStorageFile(const string& path) {
  map<string, time_t> storage;
	
  XMLDocument doc;
  if (doc.LoadFile(gStorage.c_str())!=XML_NO_ERROR) {
    cerr << "Error reading XML!" << endl;
    doc.PrintError();
  }
  auto root  = doc.FirstChildElement();
  auto file = root->FirstChildElement();
  while (file) {
    string name = file->FirstAttribute()->Value();
    auto time = file->Attribute("last_modif");
    storage[name] = stoll(time);
    file = file->NextSiblingElement();
  }

  set<string> dst;
  fs::path current(path);
  fs::recursive_directory_iterator end;
  cout << "Go to directory iterator: " << current.string() << " -> " << endl;
  for (fs::recursive_directory_iterator item(current); item != end; ++item) {
    if (!fs::is_directory(item->status())) {
      fs::path filename = item->path();

      time_t time = fs::last_write_time(filename);
      auto sfile = filename.string().substr(current.string().size());
      if (storage.count(sfile)>0) {
	if (storage[sfile]!=time) {
          dst.insert(sfile);
	  cout << "[mod] " << sfile << endl;
	}
      }
      else {
	dst.insert(sfile);
	cout << "[new] " << sfile << endl; 
      }
    }
  }

  return dst;
}
开发者ID:almikh,项目名称:patches-creator,代码行数:42,代码来源:patches-creator.cpp

示例6: xmlReadMeetingInfo

void XmlReader::xmlReadMeetingInfo(void)
{
    XMLDocument doc;
    doc.LoadFile(m_filename);
    if (doc.ErrorID() != 0) {
        printf("read xml error!\n");
        return;
    }
    XMLElement *root = doc.FirstChildElement("root");

    XMLElement *meetings = root->FirstChildElement("meetings");
    for (XMLElement *meeting = meetings->FirstChildElement("meeting");
         meeting;
         meeting = meeting->NextSiblingElement("meeting")) {
        XMLElement *meeting_id = meeting->FirstChildElement("meeting_id");
        XMLElement *meeting_name = meeting->FirstChildElement("meeting_name");
        XMLElement *start_time = meeting->FirstChildElement("start_time");
        XMLElement *end_time = meeting->FirstChildElement("end_time");
        XMLElement *meeting_conferrees = meeting->FirstChildElement("meeting_conferrees");

        printf("meeting_id: %s\n", meeting_id->GetText());
        printf("meeting_name: %s\n", meeting_name->GetText());
        printf("start_time: %s\n", start_time->GetText());
        printf("end_time: %s\n", end_time->GetText());
        printf("conferreess:\n");
        if (meeting_conferrees) {
            for (XMLElement *meeting_conferree = meeting_conferrees->FirstChildElement("meeting_conferree");
                 meeting_conferree;
                 meeting_conferree = meeting_conferree->NextSiblingElement("meeting_conferree")) {

                XMLElement *user2_id = meeting_conferree->FirstChildElement("user_id");
                XMLElement *user2_account = meeting_conferree->FirstChildElement("user_acount");
                XMLElement *user2_name = meeting_conferree->FirstChildElement("user_name");

                printf("user_id: %s\n", user2_id->GetText());
                printf("user_account: %s\n",  user2_account->GetText());
                printf("user_name: %s\n", user2_name->GetText());
            }
        }
        printf("\n");
    }
}
开发者ID:github188,项目名称:msm,代码行数:42,代码来源:xmlReader.cpp

示例7: XMLDocument

bool XMLOperation::fixAttribute1(const char *filePath, const char *elementId, const char *name, const char *value,const char* defId,bool fullPath)
{
    std::string fullpath_str = filePath;
    
    if (!fullPath)
    {
        fullpath_str.clear();
        fullpath_str = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(filePath);
        
    }
    
    cout<<"修改文件读取的路径:"<<fullpath_str<<endl;
    
    XMLDocument *pDoc = new XMLDocument();
    pDoc->LoadFile(fullpath_str.c_str());
    
    XMLElement *rootElement = pDoc->FirstChildElement();
    XMLElement *xElement = rootElement->FirstChildElement();
    
    bool isFixed = false;
    
    while (xElement)//一条记录
    {
        if (strcmp(xElement->Attribute(defId),elementId) == 0)
        {
            xElement->SetAttribute(name, value);
//            cout<<"属性id 值:"<<xElement->Attribute(defId)<<"比较id "<<elementId<<" name "<<name<<" value:"<<value<<endl;
            
        if (pDoc->SaveFile(fullpath_str.c_str()) == XML_SUCCESS) {
                isFixed = true;
            }
            break;

        }
    
        xElement = xElement->NextSiblingElement();
    }
    
    delete pDoc;
    
    return isFixed;
}
开发者ID:GHunique,项目名称:CrazyGeography1,代码行数:42,代码来源:XMLOperation.cpp

示例8: readXML

void XMLOperation::readXML(const char *filePath)
{
    XMLDocument *pDoc = new XMLDocument();
    pDoc->LoadFile(filePath);
    
    XMLElement *rootElement = pDoc->FirstChildElement();
    XMLElement *xElement = rootElement->FirstChildElement();
    
    while (xElement) {
        
        cout<<xElement->Name()<<endl;
        
        XMLOperation::readAttribute(xElement, _xmlDic);
        
        xElement = xElement->NextSiblingElement();
    }
    
    delete pDoc;
    
}
开发者ID:GHunique,项目名称:CrazyGeography1,代码行数:20,代码来源:XMLOperation.cpp

示例9: main

int main (int argc, char const* argv[])
{
    XMLDocument doc;
    
    doc.LoadFile("resource/example4.xml");
    
    XMLElement* element = doc.FirstChildElement("MyApp");
    element = element->FirstChildElement("Messages")->FirstChildElement("value");

    if(element){
        float value;
        element->QueryFloatText(&value);

        cout<< value+2 << endl;
    }else{
        cout<<"not found"<<endl;
    }
    
    return 0;
}
开发者ID:jcarlosadm,项目名称:tutorials,代码行数:20,代码来源:test01.cpp

示例10: readXML

	void ImageMapWorldCreator::readXML(MapDirectory* mapDirectory, Engine* engine, SDL_Surface* surface, World* world)
	{
		XMLDocument document;
		if (document.LoadFile(mapDirectory->getXMLPath().c_str()) == XML_NO_ERROR) {
			XMLElement* mapElement = document.FirstChildElement("map");
			if (mapElement) {
				XMLElement* backgroundsElement = mapElement->FirstChildElement("backgrounds");
				XMLElement* texturesElement = mapElement->FirstChildElement("textures");
				if (texturesElement) {
					readTexturesElement(texturesElement, surface);
				}
				if (backgroundsElement) {
					readBackgroundsElement(backgroundsElement, engine, mapDirectory, world);
				}
			}
		} else {
			cout << document.GetErrorStr1() << endl;
			cout << document.GetErrorStr2() << endl;
		}
	}
开发者ID:snosscire,项目名称:Block-World,代码行数:20,代码来源:ImageMapWorldCreator.cpp

示例11: loadShortcut

// TODO : error checking
Result loadShortcut(shortcut_s* s, char* path)
{
    if(!s || !path)return -1;

    XMLDocument doc;
    if(doc.LoadFile(path))return -2;

    XMLElement* shortcut = doc.FirstChildElement("shortcut");
    if(shortcut)
    {
        XMLElement* executable = shortcut->FirstChildElement("executable");
        if(executable)
        {
            const char* str = executable->GetText();
            if(str)
            {
                s->executable = (char*)malloc(strlen(str) + 1);
                if(s->executable) strcpy(s->executable, str);
            }
        }
        if(!s->executable) return -3;

        XMLElement* descriptor = shortcut->FirstChildElement("descriptor");
        const char* descriptor_path = path;
        if(descriptor) descriptor_path = descriptor->GetText();
        if(descriptor_path)
        {
            s->descriptor = (char*)malloc(strlen(descriptor_path) + 1);
            if(s->descriptor) strcpy(s->descriptor, descriptor_path);
        }

        loadXmlString(&s->icon, shortcut, "icon");
        loadXmlString(&s->arg, shortcut, "arg");
        loadXmlString(&s->name, shortcut, "name");
        loadXmlString(&s->description, shortcut, "description");
        loadXmlString(&s->author, shortcut, "author");

    } else return -4;

    return 0;
}
开发者ID:RedInquisitive,项目名称:3DS-Homebrew-Menu,代码行数:42,代码来源:shortcut.cpp

示例12: reloadHighScore

void highscore::reloadHighScore()
{
    string playerNameTMP;
    int scoreTMP;

    // Clear highscore list first
    this->highScoreData.clear();

    // Initialize XML reader
    XMLDocument xmlHighScore;
    XMLElement *nodeTransversal;
    xmlHighScore.LoadFile("score.xml");

    // Get first child
    nodeTransversal = xmlHighScore.FirstChildElement("hs");
    playerNameTMP = string(nodeTransversal->FirstChildElement("name")->GetText());
    scoreTMP = atoi(nodeTransversal->FirstChildElement("score")->GetText());
    this->addScore(playerNameTMP, scoreTMP);

    // Get all node
    while(true)
    {
        nodeTransversal = nodeTransversal->NextSiblingElement("hs");
        if(nodeTransversal)
        {
            playerNameTMP = string(nodeTransversal->FirstChildElement("name")->GetText());
            scoreTMP = atoi(nodeTransversal->FirstChildElement("score")->GetText());
            this->addScore(playerNameTMP, scoreTMP);
        }
        else
        {
            break;
        }
    }

    // Sort highscore depend on its score
    this->highScoreData.sort(hsComp);



}
开发者ID:dwipasawitra,项目名称:simple-tetris,代码行数:41,代码来源:highscores.cpp

示例13: xmlReadMsmServerInfo

void XmlReader::xmlReadMsmServerInfo(void)
{
    XMLDocument doc;
    doc.LoadFile(m_filename);
    if (doc.ErrorID() != 0) {
        printf("read xml error!\n");
        return;
    }
    XMLElement *root = doc.FirstChildElement("root");

    XMLElement *msms = root->FirstChildElement("msms");
    for (XMLElement *msm = msms->FirstChildElement("msm");
         msm;
         msm = msm->NextSiblingElement("msm")) {
        XMLElement *msm_ip = msm->FirstChildElement("msm_ip");
        XMLElement *msm_port = msm->FirstChildElement("msm_port");

        printf("msm_ip: %s\n", msm_ip->GetText());
        printf("msm_port: %s\n", msm_port->GetText());
    }
}
开发者ID:github188,项目名称:msm,代码行数:21,代码来源:xmlReader.cpp

示例14: load

std::string SystemSettings::load(const K::File& file) {

	XMLDocument doc;
	doc.LoadFile( file.getAbsolutePath().c_str() );

	XMLElement* nRoot = doc.FirstChildElement("KSynth");
	if (nRoot == nullptr) {return "";}

	// list of all encountered problems;
	std::string problems;

	XMLElement* nSettings = nRoot->FirstChildElement("Settings");
	if (!nSettings) {return "missing node for 'Settings'\n";}

	// sound-sink
	XMLElement* nSink = nSettings->FirstChildElement("SoundSink");
	if (nSink) {
		std::string name = nSink->Attribute("name");
		SoundSinkHardware* ss = SoundSinks::get().getHardwareSinkByName(name);
		if (ss) {
			setSoundSink(ss);
		} else {
			problems += "could not find a SoundSink named '"+name+"'\n";
		}
	} else {
		problems += "no 'SoundSink' given\n";
	}

	// refresh interval
	XMLElement* nGui = nSettings->FirstChildElement("GUI");
	if (nGui) {
		XMLElement* nGuiRefresh = nGui->FirstChildElement("Refresh");
		if (nGuiRefresh) {
			setGuiRefreshInterval(nGuiRefresh->IntAttribute("ms"));
		}
	}

	return problems;

}
开发者ID:k-a-z-u,项目名称:KSynth,代码行数:40,代码来源:SystemSettings.cpp

示例15: CCLog

void XMLOperation::readXML1(const char *filePath)
{
    CCLog("读取xml文件路径: %s",filePath);
    
    XMLDocument *pDoc = new XMLDocument();
    pDoc->LoadFile(filePath);
    
    XMLElement *rootElement = pDoc->FirstChildElement();
    XMLElement *xElement = rootElement->FirstChildElement();
    
    while (xElement) {
    
        if (SHOW_MODULE) cout<<"<"<<xElement->Name()<<">"<<endl;
        
        XMLOperation::readAttribute1(xElement,_xmlDic1);
        
        xElement = xElement->NextSiblingElement();
    }
    
    delete pDoc;
    
}
开发者ID:GHunique,项目名称:CrazyGeography1,代码行数:22,代码来源:XMLOperation.cpp


注:本文中的XMLDocument::FirstChildElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。