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


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

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


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

示例1: WideCharToMultiByte

wchar_t *GetProductID(wchar_t *path)
{
	char *buf = NULL;
	UnZipFile(path, "WMAppManifest.xml", &buf, NULL);
	char *newBuf = NULL;
	if (buf)
	{
		const char *result = NULL;
		XMLDocument doc;

		if (doc.Parse(buf))
		{
			int outputSize = WideCharToMultiByte(CP_UTF8, 0, (wchar_t*)buf, -1, NULL, 0, NULL, NULL);
			newBuf = new char[outputSize];
			WideCharToMultiByte(CP_UTF8, 0, (wchar_t*)buf, -1, newBuf, outputSize, NULL, NULL);

			doc.Parse(newBuf);
			delete[] newBuf;
			if (doc.ErrorID())
			{
				return NULL;
			}
		}
		char *levels[] = {"Deployment", "App", "ProductID"};
		int levelCount = 3;
		XMLElement* elem = doc.FirstChildElement(levels[0]);
		for (int i = 1; i < levelCount; i++)
		{
			if (i == (levelCount - 1))
			{
				result = elem->Attribute(levels[i]);
			}
			else
			{
				elem = elem->FirstChildElement(levels[i]);
				if (!elem)
					break;
			}
		}
		if (result)
		{
			wchar_t *str = new wchar_t[strlen(result) + 1];
			mbstowcs(str, result, strlen(result) + 1);
			return str;
		}
	}
	return NULL;
}
开发者ID:ultrashot,项目名称:xapdeployer-native,代码行数:48,代码来源:XapDeployer.cpp

示例2: paeseXml

void LoadScene::paeseXml()
{
    ValueVector xmlVector;
    
    //    //xml解析
    //string fileName="loadXml";
    //std::string filePath = FileUtils::getInstance()->getWritablePath() + fileName;
    
    //std::string filePath=cocos2d::FileUtils::getInstance()->getStringFromFile("loadPicture.xml");
    //获取文件在系统的绝对路径
    //std::string filePath1=FileUtils::getInstance()->fullPathForFilename("loadPicture.xml");
    //log("%s",filePath1.c_str());
    XMLDocument *pDoc = new XMLDocument();
    Data fileData=FileUtils::getInstance()->getDataFromFile("loadPicture.xml");
    pDoc->Parse((const char*)fileData.getBytes());//开始解析
    //    XMLError errorId = pDoc->LoadFile(filePath1.c_str());
    //    if (errorId != 0) {
    //        //xml格式错误
    //        log("cuowu");
    //    }
    //获取第一个节点属性
    XMLElement *rootEle = pDoc->RootElement();
    const XMLAttribute *attribute = rootEle->FirstAttribute();
    //打印节点属性名和值
    log("attribute<em>name = %s,attribute</em>value = %s", attribute->Name(), attribute->Value());
    
    loadXmlElement(rootEle);
    delete pDoc;
}
开发者ID:LiZhengyan,项目名称:mycocos,代码行数:29,代码来源:LoadScene.cpp

示例3: parsePages

void Book::parsePages(BLUnZip& zip)
{
    for (size_t i = 0; i < m_spine.size(); ++i)
    {
        std::string data = zip.ExtractToString(m_container + m_manifest[m_spine[i]]);

        XMLDocument doc;
        doc.Parse(data.c_str());

        XMLElement* html = doc.FirstChildElement("html");
    	XMLElement* body = html->FirstChildElement("body");
        
        for (XMLElement* next = body->FirstChildElement(); next != nullptr; next = next->NextSiblingElement())
        {
        	if (next)
        	{
        		const char* textStr = next->GetText();
			if (textStr)
			{
				std::string str(textStr);
				shortenString(m_text, str);
			}
        	}
        }
    }
}
开发者ID:reworks,项目名称:3DS_eBook_Reader,代码行数:26,代码来源:Book.cpp

示例4: parseOPF

void Book::parseOPF(BLUnZip& zip)
{
    std::string data = zip.ExtractToString(m_opf);
    
    XMLDocument doc;
    doc.Parse(data.c_str());

    XMLElement* package = doc.FirstChildElement("package");
    XMLElement* metadata = package->FirstChildElement("metadata");
    XMLElement* manifest = package->FirstChildElement("manifest");
    XMLElement* item = manifest->FirstChildElement("item");

    m_title = metadata->FirstChildElement("dc:title")->GetText();
    m_author = metadata->FirstChildElement("dc:creator")->GetText();

    for(XMLElement* rfe = item; rfe != nullptr; rfe = rfe->NextSiblingElement("item"))
    {
       m_manifest.emplace(rfe->Attribute("id"), rfe->Attribute("href"));
    }

    XMLElement* spine = package->FirstChildElement("spine");
    XMLElement* itemref = spine->FirstChildElement("itemref");

    for (XMLElement* it = itemref; it != nullptr; it = it->NextSiblingElement("itemref"))
    {
        m_spine.push_back(it->Attribute("idref"));
    }
}
开发者ID:reworks,项目名称:3DS_eBook_Reader,代码行数:28,代码来源:Book.cpp

示例5: parseDocumentFromString

		void XMLUtil::parseDocumentFromString(XMLDocument &doc, const string &xml)
		{
			XMLError err = doc.Parse(xml.c_str());
			if (err != XMLError::XML_SUCCESS) {
				throw XMLParseException("Failed to parse invalid XML");
			}
		}
开发者ID:deltaforge,项目名称:nebu-common-cpp,代码行数:7,代码来源:xmlUtil.cpp

示例6: textMessage

int textMessage(lua_State *l) {
  LUA_BRIDGE_START;

  LOGV("Lua call: textMessage");

  if (lua_gettop(l) != 1) {
    LOGW("Wrong argument count for textMessage call");
    return -1;
  }

  std::shared_ptr<CGUITextBox::SResult> result(new CGUITextBox::SResult);
  result->mResult = CGUITextBox::RESULT_NONE;

  XMLDocument doc;
  doc.Parse(lua_tostring(l, 1));

  CMessageHandler::getSingleton().addMessage(CMessageCreator::getSingleton().createMessage(doc.FirstChildElement(), Ogre::Any(result)));

  while (true) {
    LUA_WAIT(50);
    result->mMutex.lock();
    if (result->mResult != CGUITextBox::RESULT_NONE) {
      break;
    }
    result->mMutex.unlock();
  }

  // still locked
  lua_pushnumber(l, result->mResult);
  result->mMutex.unlock();
  return 1; // 1 return value
}
开发者ID:ChWick,项目名称:Zelda,代码行数:32,代码来源:UserLuaScriptBridge.cpp

示例7: example_4

bool example_4()
{
	static const char* xml =
		"<information>"
		"	<attributeApproach v='2' />"
		"	<textApproach>"
		"		<v>2</v>"
		"	</textApproach>"
		"</information>";

	XMLDocument doc;
	doc.Parse( xml );

	int v0 = 0;
	int v1 = 0;

	XMLElement* attributeApproachElement = doc.FirstChildElement()->FirstChildElement( "attributeApproach" );
	attributeApproachElement->QueryIntAttribute( "v", &v0 );

	XMLElement* textApproachElement = doc.FirstChildElement()->FirstChildElement( "textApproach" );
	textApproachElement->FirstChildElement( "v" )->QueryIntText( &v1 );

	printf( "Both values are the same: %d and %d\n", v0, v1 );

	return !doc.Error() && ( v0 == v1 );
}
开发者ID:AlejandorLazaro,项目名称:tinyxml2,代码行数:26,代码来源:xmltest.cpp

示例8: Read

REBOOL REXMLSerializableReader::Read(const REString & xmlString)
{
#ifndef __RE_NO_XML_PARSER_PRIVATE__	
	_totalElementsCount = 0;
	_processedElementsCount = 0;
	_isError = false;
	if (_controller && _callBack.CreateNewObject) 
	{
		XMLDocument doc;
		doc.Parse(xmlString.UTF8String());
		
		if (doc.Error()) { return false; }
		
		XMLElement * root = doc.RootElement();
		if (root == NULL) { return false; }
		
		const char * rootVal = root->Value();
		if (rootVal) 
		{
			if (strcmp(rootVal, "viewcontroller") == 0) 
			{
				_totalElementsCount = this->CalculateElements(root);
#if 0				
				if ( this->ParseObject(root, _controller, _controller) ) 
				{
					return true;
				}
#endif				
				_isError = true;
			}
		}
	}
#endif
	return false;
}
开发者ID:OlehKulykov,项目名称:re-sdk,代码行数:35,代码来源:REXMLSerializableReader.cpp

示例9: example_2

int example_2()
{
	static const char* xml = "<element/>";
	XMLDocument doc;
	doc.Parse( xml );

	return doc.ErrorID();
}
开发者ID:AlejandorLazaro,项目名称:tinyxml2,代码行数:8,代码来源:xmltest.cpp

示例10: data

model::describe_snapshots_response::describe_snapshots_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	XMLNode *RootNode = doc.FirstChild();
	XMLElement *Element = RootNode->FirstChildElement("requestId");
	if(Element!=NULL)
	{
		request_id = Element->GetText();
		Element=Element->NextSiblingElement();
	}
	else cout<<"Error Parsing Request ID from XML describe_snapshots_response\n";
	XMLElement *ListElement = Element->FirstChildElement("item");
	XMLElement *SnapshotElement;
	string status, snapshot_id,  start_time, volume_id;
	float volume_size;
	while(ListElement != NULL)
	{
		SnapshotElement = ListElement->FirstChildElement("status");
		if(SnapshotElement!=NULL)
		{
			status = SnapshotElement->GetText();
			SnapshotElement = SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing status from XML describe_snapshots_response\n";

		if(SnapshotElement!=NULL)
		{	
			snapshot_id = SnapshotElement->GetText();
			SnapshotElement=SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing snapshot_id from XML describe_snapshots_response\n";

		if(SnapshotElement!=NULL)
		{
			SnapshotElement->QueryFloatText(&volume_size);
			SnapshotElement=SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing volume_size from XML describe_snapshots_response\n";
		
		if(SnapshotElement!=NULL)
		{
			volume_id=SnapshotElement->GetText();
			SnapshotElement=SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing volume_id from XML describe_snapshots_response\n";
		
		if(SnapshotElement!=NULL)
			if(SnapshotElement->GetText()!=NULL) start_time = SnapshotElement->GetText();
		else cout<<"Error Parsing start_time from XML describe_snapshots_response\n";
		//add to map
		model::snapshot data(status,snapshot_id,volume_size,volume_id,start_time);
		snapshot_set.push_back(data);
		ListElement=ListElement->NextSiblingElement();
	}

}
开发者ID:sumanswaroop,项目名称:jcs_cpp_sdk,代码行数:58,代码来源:describe_snapshots_response.cpp

示例11:

model::delete_snapshot_response::delete_snapshot_response(const string &xml_doc):result(false)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	const XMLNode *RootNode = doc.FirstChild();
  if (RootNode) {
    set_string_value(RootNode, "requestId", request_id);
    set_bool_value(RootNode, "return", result);
  }
}	
开发者ID:JioCloudCompute,项目名称:jcs_cpp_sdk,代码行数:11,代码来源:delete_snapshot_response.cpp

示例12: initialize

bool AudioResourceManager::initialize()
{
    srand(time(NULL));
    Ogre::String path = Ogre::macBundlePath() + "/Contents/Resources/media/config/audio_events.xml";
    //xml_document<> doc;    // character type defaults to char
    FILE *audioConfigFile = fopen(path.data(), "r");
    
    std::vector<char> buffer;
    int c;
    while (EOF !=(c=getc(audioConfigFile))){
        buffer.push_back(c);
    }
   
    
    char buf[buffer.size()];
    for (int i = 0; i < buffer.size(); i++){
        buf[i] = buffer[i];
    }
    XMLDocument doc;
    doc.Parse(buf);

    XMLElement *eventIter = doc.FirstChildElement()->FirstChildElement();
    
    
    unsigned int currentHandle = 0;
    
    while (eventIter != NULL)
    {
        XMLNode *unitIter = eventIter->FirstChildElement()->NextSiblingElement();
        std::string eventName = eventIter->FirstChildElement()->GetText();
        
        while (unitIter != NULL) {
            AudioResource unit;
            
            unit.filename = unitIter->FirstChildElement("filename")->GetText();// first_node("filename")->value();
            printf("filename: %s\n", unit.filename.c_str());
            unit.panning = atof(unitIter->FirstChildElement("panning")->GetText());
            unit.pitch = atof(unitIter->FirstChildElement("pitch")->GetText());
            unit.looping = atoi(unitIter->FirstChildElement("looping")->GetText());
            unit.gain = atof(unitIter->FirstChildElement("gain")->GetText());
            unit.bufferHandle = -1;
            unit.sourceHandle = -1;
            if ( eventName == "apply_force_left" || eventName == "apply_force_right" || eventName=="fall_off") unit.canStop = false;
            else unit.canStop = true;
            alGenSources(1, &unit.sourceHandle);
            resources[eventName].push_back(unit);
            
            unitIter = unitIter->NextSibling();
        }
        
        eventIter = eventIter->NextSiblingElement();
    }
    return true;
}
开发者ID:OneGameAMonth,项目名称:1GAM-Jan-HaikuRacer,代码行数:54,代码来源:AudioResourceManager.cpp

示例13: albumGetInfo

XMLDocument* LastFmClient::albumGetInfo(string mbid) {
	ostringstream oss;
	oss << METADATA_SERVER_NAME 
			<< "?method=album.getInfo"
			<< "&mbid=" << mbid
			<< "&api_key=" << LASTFM_API_KEY;
	
	string response = client.get(oss.str());
	XMLDocument* doc = new XMLDocument();
	doc->Parse(response.c_str());
    return doc;
}
开发者ID:0x20h,项目名称:mp3sort,代码行数:12,代码来源:LastFmClient.cpp

示例14: fingerprintGetMetadata

XMLDocument* LastFmClient::fingerprintGetMetadata(int fpid) {
	ostringstream oss;
	oss << METADATA_SERVER_NAME 
			<< "?method=track.getfingerprintmetadata"
			<< "&fingerprintid=" << fpid
			<< "&api_key=" << LASTFM_API_KEY;
	
	string response = client.get(oss.str());
	XMLDocument* doc = new XMLDocument();
	doc->Parse(response.c_str());
    return doc;	
}
开发者ID:0x20h,项目名称:mp3sort,代码行数:12,代码来源:LastFmClient.cpp

示例15: CCLOG

std::vector<MapSelectData> XMLMapListParser::loadXMLFile(const char *xmlFileName)
{
    
    std::vector<MapSelectData> data ;
    
    std::string fullPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(xmlFileName);
    
    unsigned long dataSize = 0;
    unsigned char* pFileData = NULL;
    
    pFileData = (unsigned char*) CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "r", &dataSize);
    //    CCLOG("Empty file: %s", fullPath.c_str());
    
    if (!pFileData)
    {
        //        CCLOG("Empty file: %s", fullPath.c_str());
        return data;
    }
    std::string fileContent;
    fileContent.assign(reinterpret_cast<const char*>( pFileData), dataSize);
    
    XMLDocument document;
    if( document.Parse(fileContent.c_str()) != XML_NO_ERROR)
    {
        CCLOG("Cannot parse file: %s", fullPath.c_str());
        return data;
    }
    
    //Parse data
    XMLElement* docElement = document.FirstChildElement();
    if(docElement != NULL)
    {
        for(XMLElement* child = docElement->FirstChildElement(TAG_MAP) ; child!=NULL ; child = child->NextSiblingElement())
        {
            MapSelectData mdata;
            
            TextureSelector selector;
            selector.activeTexture = selector.deactiveTexture = readNormalIcon(child);
            selector.selectedTexture = readSelectedIcon(child);
            mdata.setSelector(selector);
            
            mdata.setID(readID(child));
            mdata.setstate(readState(child));
            mdata.buttonID = XMLHelper::readAttributeString(child, ATTRIBUTE_BUTTON_ID, "s");
            
            data.push_back(mdata);
        }
    }
    
    delete []pFileData;
    return data;
}
开发者ID:quinsmpang,项目名称:TinyZodiacs,代码行数:52,代码来源:XMLMapListParser.cpp


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