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


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

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


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

示例1: TVTAddXMLLine

LPVOID	TVTCreateXMLPacket4FinalizeSession(
	TCHAR*	sessionName,
		int	failureCount,
		int	summaryCount,
		int	numberOfTests,
		int	numberOfSuccessfulTests,
		int	numberOfUnsuccessfulTests)
{
	TCHAR*	result	= null,
		templatePath[MAX_PATH],
			tempText[MAX_PATH]	
	;
	if (!GetTemplateActionPath(templatePath)
	)	return	result
	;
//	This open and parse the XML file:  
	XMLNode	xRootNode	= XMLNode::openFileHelper(templatePath,"easyTest");
	XMLNode	xAction		= xRootNode.getChildNode("Action");
	XMLAttribute*	xAttribute	= xAction.AddAttribute(stringDup("command",0),stringDup("updateObject",	0));
	XMLNode	xAttributes	= xAction.getChildNode("Attributes");
	xAttribute	= xAttributes.AddAttribute(stringDup("object",	0),stringDup("session",		0));
	xAttribute	= xAttributes.AddAttribute(stringDup("session",	0),stringDup(sessionName,	0));
	
	XMLNode	xEntity	= xAction.AddChild(stringDup("Entity"),0);

//	Line 'Conclusion'
	XMLNode	xLine	= TVTAddXMLLine(xEntity);
	TVTAddXMLToken(xLine,"Conclusion: ");
	TVTAddXMLToken(xLine,itoa(summaryCount,tempText,10));
	TVTAddXMLToken(xLine," checks were made. There were ");
	TVTAddXMLToken(xLine,itoa(failureCount,tempText,10));
	TVTAddXMLToken(xLine," failures.");
	
//	Line 'Statistics'
	xLine	= TVTAddXMLLine(xEntity);
	TVTAddXMLToken(xLine,"Statistics:");
//	Line # tests are executes.
	xLine	= TVTAddXMLLine(xEntity);
	TVTAddXMLToken(xLine,itoa(numberOfTests,tempText,10));
	if (numberOfTests == 1)
		TVTAddXMLToken(xLine," test is executed.");
	else
		TVTAddXMLToken(xLine," tests are executed.")
	;
	xLine	= TVTAddXMLLine(xEntity);
	if (!numberOfUnsuccessfulTests)
	{
			TVTAddXMLToken(xLine,"No errors detected.");
	}
	else
	{
			TVTAddXMLToken(xLine,itoa(numberOfSuccessfulTests,tempText,10));
			if (numberOfSuccessfulTests == 1)
				TVTAddXMLToken(xLine," test is completed successfully. ");
			else
				TVTAddXMLToken(xLine," tests are completed successfully. ")
			;
		xLine	= TVTAddXMLLine(xEntity);
			TVTAddXMLToken(xLine,itoa(numberOfUnsuccessfulTests,tempText,10));
			if (numberOfUnsuccessfulTests == 1)
				TVTAddXMLToken(xLine," test failed.");
			else
				TVTAddXMLToken(xLine," tests failed.")
			;
	}

//	Line
	int		size;
	LPTSTR	pText	= xRootNode.createXMLString(1,&size);
	result	= new TCHAR [size+1];
	if (result)
	{
		_tcscpy(result,pText);
	}
	free(pText);
	return	result;
}
开发者ID:Nuos,项目名称:codeproject,代码行数:77,代码来源:TestRegistry.cpp

示例2: assert


//.........这里部分代码省略.........
          // If we found a closing tag...
          // Eg.  '>'
        case eTokenCloseTag:
          // We are now outside the tag
          status = eOutsideTag;
          break;

          // If we found a short hand '/>' closing tag then we can
          // return to the caller
        case eTokenShortHandClose:
          return true;

          // Errors...
        case eTokenQuotedText: /* '"SomeText"'   */
        case eTokenTagStart: /* '<'            */
        case eTokenTagEnd: /* '</'           */
        case eTokenEquals: /* '='            */
        case eTokenDeclaration: /* '<?'           */
          pXML->error = eXMLErrorUnexpectedToken;
          return false;
        default:
          break;
        }
        break;

        // If we are looking for an equals
      case eAttribEquals:
        // Check what the current token type is
        switch (token.type) {
          // If the current type is text...
          // Eg.  'Attribute AnotherAttribute'
        case eTokenText:
          // Add the unvalued attribute to the list
          node.AddAttribute(std::move(attribute_name), _T(""), 0);
          // Cache the token then indicate.  We are next to
          // look for the equals attribute
          attribute_name.assign(token.pStr, token.length);
          break;

          // If we found a closing tag 'Attribute >' or a short hand
          // closing tag 'Attribute />'
        case eTokenShortHandClose:
        case eTokenCloseTag:
          assert(!attribute_name.empty());

          // If we are a declaration element '<?' then we need
          // to remove extra closing '?' if it exists
          if (node.IsDeclaration() && attribute_name.back() == _T('?')) {
            attribute_name.pop_back();
          }

          if (!attribute_name.empty())
            // Add the unvalued attribute to the list
            node.AddAttribute(std::move(attribute_name), _T(""), 0);

          // If this is the end of the tag then return to the caller
          if (token.type == eTokenShortHandClose)
            return true;

          // We are now outside the tag
          status = eOutsideTag;
          break;

          // If we found the equals token...
          // Eg.  'Attribute ='
        case eTokenEquals:
开发者ID:Advi42,项目名称:XCSoar,代码行数:67,代码来源:Parser.cpp


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