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


C++ XMLNode::Parent方法代码示例

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


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

示例1: WriteToDoc

void OutputWriter::WriteToDoc(ResponseMsg response, XMLNode* node, const char* value){
	std::string path = CommandManager::getPathOut();
	tinyxml2::XMLDocument* doc = CommandManager::getDocOut();

	//Searching root
	XMLNode *root = node;
	while(strcmp(root->Value(),"command")!=0)
	{root=root->Parent();}

	XMLText* textCode = doc->NewText((Utils::convertInt(response.getCode()).c_str()));
	XMLText* textMessage = doc->NewText(response.getMessage());
	XMLText* valueMessage = doc->NewText(value);

	node->DeleteChildren();
	XMLElement* codeElement = doc->NewElement("code");
	node->InsertEndChild(codeElement);
	XMLElement* messageElement = doc->NewElement("message");
	node->InsertEndChild(messageElement);
	XMLElement* valueElement = doc->NewElement("value"); 	//Insert the value
	node->InsertEndChild(valueElement);

	codeElement->InsertEndChild(textCode);
	messageElement->InsertEndChild(textMessage);
	valueElement->InsertEndChild(valueMessage);

	XMLElement* commandsElement = doc->FirstChildElement("commands");
	commandsElement->InsertEndChild(root);
}
开发者ID:gabriman,项目名称:CameraControlInterface,代码行数:28,代码来源:OutputWriter.cpp

示例2: main


//.........这里部分代码省略.........
	XMLNode *rootnode = doc.FirstChild();
	//////////////////////////////
	rootnode = rootnode->NextSibling();
	rootnode = rootnode->FirstChild();////////////hard code to get past the xml header into <ITEM> </ITEM portion
	rootnode = rootnode->FirstChild();
	rootnode = rootnode->NextSibling();
	///////////////////////////////////
	
	while(loopFlag==true){
		if(std::strcmp(rootnode->Value(),"item") != 0){   
			rootnode = rootnode->NextSibling();
		}
		else 
			loopFlag=false;
	}


	while(bigLoop==true){
		XMLHandle safe = rootnode;
		if(safe.ToNode()==NULL)
			bigLoop=false;
		else{
			NewsEntry *story = new NewsEntry(); 
			rootnode = rootnode->FirstChild();
			rootnode = rootnode->NextSibling();
			rootnode = rootnode->FirstChild();
			story->setTitle(rootnode->Value());
			for(int x=0; x<strCount; x++){
				if(story->getTitle().compare(headlines[x])==0){
					storyExists = true;
				}

			}	

			if(storyExists==false){
				if(soundFlag==true){
					PlaySound(TEXT("sportscenter.wav"), NULL, SND_FILENAME | SND_ASYNC);
				}
				std::cout<< story->getTitle() <<std::endl;
				a_file << story->getTitle();
				a_file << "\n";
				headlines[strCount] = story->getTitle();
				strCount++;
			}
			
		
			rootnode = rootnode->Parent();
			rootnode = rootnode->NextSibling();
			rootnode = rootnode->FirstChild();
			story->setDescription(rootnode->Value());
			if(storyExists==false){
				std::cout<< story->getDescription() <<std::endl;
				a_file << story->getDescription();
				a_file << "\n";
			}
			
			rootnode = rootnode->Parent();
			rootnode = rootnode->NextSibling();
			rootnode = rootnode->FirstChild();
			story->setPubDate(rootnode->Value());
			if(storyExists==false){
				std::cout << story->getPubdate() <<std::endl;
				a_file << story->getPubdate();
				a_file << "\n";
			}
		
			rootnode = rootnode->Parent();
			rootnode = rootnode->NextSibling();
			
			rootnode = rootnode->FirstChild();
			story->setLink(rootnode->Value());
			if(storyExists==false){
				//std::cout<< story->getLink() << std::endl;
				a_file << story->getLink();
				a_file << "\n";
				a_file << "\n";
				printf("\n");
			}
			
			rootnode = rootnode->Parent();
			
			rootnode = rootnode->Parent();
			rootnode = rootnode->NextSibling();
			delete story;
			storyExists = false;
			
		}
	}

	pageSwitch++;
	if(pageSwitch>3){
		pageSwitch = 0;
		soundFlag=true;
	}
	a_file.close();
	Sleep(100000);
  }
	
  return 0;
}
开发者ID:jakeb15,项目名称:ESPN_XML,代码行数:101,代码来源:ESPN_XML.cpp


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