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;
}
Example #2
0
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;
}
Example #3
0
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);
			}
        	}
        }
    }
}
Example #4
0
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"));
    }
}
Example #5
0
		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");
			}
		}
Example #6
0
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
}
Example #7
0
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 );
}
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;
}
Example #9
0
int example_2()
{
	static const char* xml = "<element/>";
	XMLDocument doc;
	doc.Parse( xml );

	return doc.ErrorID();
}
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();
	}

}
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);
  }
}	
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;
}
Example #13
0
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;
}
Example #14
0
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;	
}
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;
}
Example #16
0
XMLDocument* LastFmClient::albumGetInfo(string artist, string album) {
	ostringstream oss;
	oss << METADATA_SERVER_NAME << "?" 
			<< "method=album.getInfo"
			<< "&album=" << client.encode(album)
			<< "&artist=" << client.encode(artist)
			<< "&api_key=" << LASTFM_API_KEY;
	
	string response = client.get(oss.str());
	XMLDocument* doc = new XMLDocument();
	doc->Parse(response.c_str());
    return doc;
}
Example #17
0
void Book::ParseContainer(BLUnZip& zipfile)
{
	std::string unclean( zipfile.ExtractToString("META-INF/container.xml") );

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

    XMLElement* container = doc.FirstChildElement( "container" );
    XMLElement* rootfiles = container->FirstChildElement( "rootfiles" );
    XMLElement* rootfile = rootfiles->FirstChildElement( "rootfile" );

    opf = rootfile->Attribute("full-path");
}
Example #18
0
void LoadMeshFromCollada(const char* relativeFileName, btAlignedObjectArray<GLInstanceGraphicsShape>& visualShapes, btAlignedObjectArray<ColladaGraphicsInstance>& visualShapeInstances, btTransform& upAxisTransform, float& unitMeterScaling, int clientUpAxis, struct CommonFileIOInterface* fileIO)
{
	//	GLInstanceGraphicsShape* instance = 0;

	//usually COLLADA files don't have that many visual geometries/shapes
	visualShapes.reserve(MAX_VISUAL_SHAPES);

	float extraScaling = 1;  //0.01;
	btHashMap<btHashString, int> name2ShapeIndex;
	
	char filename[1024];
	if (!fileIO->findResourcePath(relativeFileName, filename, 1024))
	{
		b3Warning("File not found: %s\n", filename);
		return;
	}

	XMLDocument doc;
	//doc.Parse((const char*)filedata, 0, TIXML_ENCODING_UTF8);
	b3AlignedObjectArray<char> xmlString;
	int fileHandle = fileIO->fileOpen(filename,"r");
	if (fileHandle>=0)
	{
		int size = fileIO->getFileSize(fileHandle);
		xmlString.resize(size);
		int actual = fileIO->fileRead(fileHandle, &xmlString[0],size);
		if (actual==size)
		{
		}
	}
	if (xmlString.size()==0)
		return;

	if (doc.Parse(&xmlString[0], xmlString.size()) != XML_SUCCESS)
	//if (doc.LoadFile(filename) != XML_SUCCESS)
		return;

	//We need units to be in meter, so apply a scaling using the asset/units meter
	unitMeterScaling = 1;
	upAxisTransform.setIdentity();

	//Also we can optionally compensate all transforms using the asset/up_axis as well as unit meter scaling
	getUnitMeterScalingAndUpAxisTransform(doc, upAxisTransform, unitMeterScaling, clientUpAxis);

	btMatrix4x4 ident;
	ident.setIdentity();

	readLibraryGeometries(doc, visualShapes, name2ShapeIndex, extraScaling);

	readVisualSceneInstanceGeometries(doc, name2ShapeIndex, visualShapeInstances);
}
Example #19
0
int	main (void) {
    XMLDocument doc (false);
    doc.Parse (input);

    std::cout << "INPUT:\n" << input << "\n\n";

    XMLPrinter prn (NULL, true);
    doc.Print (&prn);
    std::cout << "XMLPrinter (not valid HTML5):\n" << prn.CStr() << "\n\n";

    XMLPrinterHTML5 html5 (NULL, true);
    doc.Print (&html5);
    std::cout << "XMLPrinterHTML5:\n" << html5.CStr() << "\n";

    return 0;
}
Example #20
0
bool GraphDataStorageXML::load(const char* fullpath, GraphData& data, StageBaseData* baseData) {
    try {
        XMLDocument doc;
        XMLDocument *myDocument = &doc;
        
        if (! FileUtils::getInstance()->isFileExist(fullpath)) return false;
        
        auto Data = FileUtils::getInstance()->getDataFromFile(fullpath);
        if (myDocument->Parse((const char*)Data.getBytes(), Data.getSize())) return false;
        //if (myDocument->LoadFile(fullpath)) return false;
        
        static GraphData s_defGraphData = {
            10/*row*/,
            10/*column*/,
            5/*vertex_num*/,
            64/*box_heights*/,
            64/*box_widths*/,
            0/*diff_row_off_x*/,
            32/*offsert_x*/,
            32/*offsert_y*/
        };
        data = s_defGraphData;
        
        for (XMLElement* property = myDocument->FirstChildElement("property"); property; property = property->NextSiblingElement("property")) {
            data.cols  = property->IntAttribute("cols");
            data.rows  = property->IntAttribute("rows");
            
            if (baseData) {
                baseData->m_bonusNeedStar = 12;
                baseData->m_lbNeedScore = property->IntAttribute("score") * 5;
            }
        }
        for (XMLElement* property = myDocument->FirstChildElement("map"); property; property = property->NextSiblingElement()) {
            for (auto attribute = property->FirstAttribute(); attribute; attribute = attribute->Next()) {
                const char* name = attribute->Name();
                int row = 0, col = 0;
                sscanf(name, "a%d_%d", &row, &col);
                data.map[row][col] = GraphAttrib::make(NodeCategory::make(static_cast<enNodeColor>(attribute->IntValue()), CHESS_CATEGORY_NORM, 0));
            }
        }
    } catch (std::string& e) {
        cocos2d::log("%s\n", e.c_str());
        return false;
    }
    return true;
}
model::delete_snapshot_response::delete_snapshot_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)
	{	if(Element->GetText()!=NULL)request_id = Element->GetText();
		Element=Element->NextSiblingElement();
	}
	else cout<<"Error Parsing request_id from XML delete_snapshot_response\n";
	
	if(Element!=NULL)
		Element->QueryBoolText(&result);
	else cout<<"Error Parsing result from XML delete_snapshot_response\n";
}	
Example #22
0
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;
            }
        }
    }
}
Example #23
0
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;
}
model::describe_instance_types_response::describe_instance_types_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)
	{
		if(Element->GetText()!=NULL) request_id = Element->GetText();
		Element=Element->NextSiblingElement();
	}
	else cout<<"Error Parsing request_id from XML describe_instance_types_response\n";
	
	XMLElement *InstanceTypeElement,*ListElement = Element->FirstChildElement("item");
	float vcpus,ram;
	string id;
	while(ListElement != NULL)
	{
		InstanceTypeElement = ListElement->FirstChildElement("vcpus");
		if(InstanceTypeElement!=NULL)
		{
			InstanceTypeElement->QueryFloatText(&vcpus);
			InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
		}
		else cout<<"Error Parsing VCPUS from XML describe_instance_types_response\n";
		if(InstanceTypeElement!=NULL)
		{	
			InstanceTypeElement->QueryFloatText(&ram);
			InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
		}
		else cout<<"Error Parsing RAM data from XML describe_instance_types_response\n";

		if(InstanceTypeElement!=NULL)
			{if(InstanceTypeElement->GetText() != NULL)id = InstanceTypeElement->GetText();}
		else cout<<"Error Parsing instance_id from XML describe_instance_types_response\n";
		//Add to map
		model::instance_type data(vcpus, ram, id);
		instance_type_set.push_back(data);

		ListElement=ListElement->NextSiblingElement();
	}
}
model::describe_volumes_response::describe_volumes_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	const XMLNode *RootNode = doc.FirstChild();
  if (RootNode) {
    set_string_value(RootNode, "requestId", request_id);
    const XMLElement * Element = RootNode->FirstChildElement("volumeSet");
    const XMLElement * ListElement = NULL;
    if (Element)
      ListElement = Element->FirstChildElement("item");
    while(ListElement != NULL)
    {
      string status,volume_id, device, instance_id, snapshot_id,create_time;
      bool encrypted = false;
      string volume_type;
      float size;

      set_string_value(ListElement, "status", status);
      set_string_value(ListElement, "volumeId", volume_id);
      //Attachment set
      const XMLElement* attachment = ListElement->FirstChildElement("attachmentSet");
      if (attachment) {
        const XMLElement* items = attachment->FirstChildElement("item");
        if (items) {
          set_string_value(items, "device", device);
          set_string_value(items, "instanceId", instance_id);
        }
      }
      set_string_value(ListElement, "snapshotId", snapshot_id);
      set_string_value(ListElement, "createTime", create_time);
      set_float_value(ListElement, "size", size);
      set_bool_value(ListElement, "encrypted", encrypted);

      model::volume data(status, volume_id, device, instance_id, snapshot_id, create_time, size, encrypted, volume_type);
      volume_set.push_back(data);

      ListElement=ListElement->NextSiblingElement();

    }
  }
}
model::start_instances_response::start_instances_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)
	{
		if(Element->GetText() != NULL)request_id = Element->GetText();
		Element = Element->NextSiblingElement();
	}	
	
	XMLElement *ListElement = Element->FirstChildElement("item");
	XMLElement *InstanceSetElement;
	string instance_id, current_state, previous_state; 
	while(ListElement != NULL)
	{
		InstanceSetElement = ListElement->FirstChildElement("instanceId");
		if(InstanceSetElement!=NULL)
		{
			if(InstanceSetElement->GetText()!=NULL)instance_id = InstanceSetElement->GetText();
			InstanceSetElement=InstanceSetElement->NextSiblingElement();
		}
		else cout<<"Error Parsing instance_id from start_instances_response";
		if(InstanceSetElement!=NULL)
		{	
			current_state = InstanceSetElement->GetText();
			InstanceSetElement=InstanceSetElement->NextSiblingElement();
		}
		else cout<<"Error Parsing current_state from XMl start_instances_response";
		
		if(InstanceSetElement!=NULL)
			{if(InstanceSetElement->GetText()!=NULL)previous_state = InstanceSetElement->GetText();}
		else cout<<"Error Parsing previous_state from XML start_instances_response";
		//Add to the map;
		model::instance_set data(instance_id, current_state, previous_state);
		instances.push_back(data);
		
		ListElement=ListElement->NextSiblingElement();
	}
}
Example #27
0
int main(int argc, char **argv)
{
	string line = "";

	if (argc == 1) {
		cout << "Enter file location: " << std::endl;
		while (line == "")
			getline(cin, line);
	}
	
	XMLDocument document;
	document.LoadFile(argc > 1 ? argv[1] : line.c_str());
	
	if (document.ErrorID() > 0)
		return document.ErrorID();
	else {
		document.Parse(line.c_str());
		auto element = document.FirstChild();
		int a =0;
	}
}
Example #28
0
static std::map<std::string, tank_t> get_tank_definitions() {
	XMLDocument doc;
	doc.Parse(get_tanks_xml_content("tanks.xml").c_str());

	XMLElement* root = doc.RootElement();

    std::map<std::string, tank_t> tanks;

    if (!root) {
        logger.writef(log_level_t::error, "Failed to load tanks.xml\n");
        return tanks;
    }

    for (XMLElement *node = root->FirstChildElement(); node; node = node->NextSiblingElement()) {
        if (!std::strcmp((const char*) node->Name(), "tank")) {
            tank_t tank = get_tank_definition(node);
            tanks[tank.icon] = tank;
        }
    }

    return tanks;
}
SkillAnimationData SkillAnimationDataFactory::loadSkillAnimationDataFromXMLFile(const char* animationId, const char* xmlFileName)
{
    SkillAnimationData 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();
    const XMLElement* result = XMLHelper::loadElementById(TAG_SKILL_ANIMATION, animationId, ATTRIBUTE_ID, docElement);
    if(result != NULL)
    {
        data = XMLSkillAnimationParser::loadData(result);
    }
    
    delete []pFileData;
    return data;

}
Example #30
0
int example_3()
{
	static const char* xml =
		"<?xml version=\"1.0\"?>"
		"<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
		"<PLAY>"
		"<TITLE>A Midsummer Night's Dream</TITLE>"
		"</PLAY>";

	XMLDocument doc;
	doc.Parse( xml );

	XMLElement* titleElement = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" );
	const char* title = titleElement->GetText();
	printf( "Name of play (1): %s\n", title );

	XMLText* textNode = titleElement->FirstChild()->ToText();
	title = textNode->Value();
	printf( "Name of play (2): %s\n", title );

	return doc.ErrorID();
}