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


C++ DOMElement::setAttribute方法代码示例

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


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

示例1: addSegmentedParagraphToSection

int addSegmentedParagraphToSection(vector<string> par, DOMElement* sect, const char* pid){
  DOMElement* aPar = NULL;
  int sid = 1;
  aPar =
  (sect->getOwnerDocument())->createElement(XMLString::transcode("paragraph"));

  aPar->setAttribute(XMLString::transcode("id"),
                     XMLString::transcode(pid));

  if ( aPar != NULL ) {
    for (vector<string>::iterator it = par.begin(); it != par.end(); it++) {
      if (verbose) cerr << "s";
      DOMElement* aSent = NULL;
      DOMElement* aSentText = NULL;
      aSent = (sect->getOwnerDocument())->createElement(XMLString::transcode("sentence"));
      aSentText = (sect->getOwnerDocument())->createElement(XMLString::transcode("text"));
      if ( (aSent != NULL) && (aSentText != NULL) ) {
        aSentText->setTextContent(XMLString::transcode((*it).c_str()));
        aSent->appendChild(aSentText);
        aPar->appendChild(aSent);
        stringstream sentId;
        sentId << pid << _ID_PREFIX_SENTENCE << sid;
        aSent->setAttribute(XMLString::transcode("id"),
                            XMLString::transcode(sentId.str().c_str()));
        sid++;
      }
    }
    sect->appendChild(aPar);
  }
  if (verbose) cerr << " ";
  return sid-1;
}
开发者ID:lgwizme,项目名称:macaon,代码行数:32,代码来源:main.cpp

示例2: WriteEntity

void EntityXMLFileWriter::WriteEntity(World* world, EntityID entity)
{
    using namespace xercesc;
    DOMDocument* doc = m_DOMImplementation->createDocument(nullptr, X("Entity"), nullptr);
    DOMElement* root = doc->getDocumentElement();
    root->setAttribute(X("xmlns:xsi"), X("http://www.w3.org/2001/XMLSchema-instance"));
    root->setAttribute(X("xsi:noNamespaceSchemaLocation"), X("../Types/Entity.xsd"));
    root->setAttribute(X("xmlns:c"), X("components"));
    const std::string& name = world->GetName(entity);
    if (!name.empty()) {
        root->setAttribute(X("name"), X(name));
    }
    
    DOMElement* componentsElement = doc->createElement(X("Components"));
    root->appendChild(componentsElement);
    appentEntityComponents(componentsElement, world, entity);

    DOMElement* childrenElement = doc->createElement(X("Children"));
    root->appendChild(childrenElement);
    appendEntityChildren(childrenElement, world, entity);

    try {
        LocalFileFormatTarget* target = new LocalFileFormatTarget(X(m_FilePath.string()));
        DOMLSOutput* output = static_cast<DOMImplementationLS*>(m_DOMImplementation)->createLSOutput();
        output->setByteStream(target);
        m_DOMLSSerializer->write(doc, output);
        delete target;
    } catch (const std::runtime_error& e) {
        LOG_ERROR("Failed to save \"%s\": %s", m_FilePath.c_str(), e.what());
    }

    doc->release();
}
开发者ID:FakeShemp,项目名称:TacticalZ,代码行数:33,代码来源:EntityXMLFileWriter.cpp

示例3: wrapXML

bool XCube::wrapXML(xercesc::DOMDocument *doc,xercesc::DOMElement *tempElem)
{
	DOMElement *cubeElem = doc->createElement(XMLString::transcode("Cube"));

	if(this->_name != "")
		cubeElem->setAttribute(XMLString::transcode("name"),XMLString::transcode(this->_name.c_str()));
	if(this->_fact != "")
		cubeElem->setAttribute(XMLString::transcode("tablename"),XMLString::transcode(this->_fact.c_str()));

	cubeElem->appendChild(tempElem);

	XSchema *tempschema = this->getSchema();
	
	DOMElement* schemaElem = doc->getDocumentElement();//create root
	
		
	if(DataSource *tempDS = tempschema->getDataSource())
	{				
			schemaElem -> appendChild(tempDS->recursiveXML(doc));
	}
	schemaElem -> appendChild(cubeElem);
	return true;
		

}
开发者ID:mydw,项目名称:mydw,代码行数:25,代码来源:XCube.cpp

示例4: saveItemsBranch

void saveItemsBranch(DOMNode* node, CTibiaTree* parent, xercesc::DOMDocument *doc)
{
	int size = parent->children.size();
	for (int i = 0; i < size; i++)
	{
		CTibiaTree* child = parent->children[i];
		if (child->HasChildren() && child->data->GetType() == TT_BRANCH_NODE)
		{
			CTibiaTreeBranchData* data = (CTibiaTreeBranchData*)(child->data);

			DOMElement* itemElem = doc->createElement(XMLString::transcode("branch"));
			itemElem->setAttribute(XMLString::transcode("name"), XMLString::transcode(data->GetName()));
			node->appendChild(itemElem);
			saveItemsBranch(itemElem, child, doc);
		}
		else if (!child->HasChildren() && child->data->GetType() == TT_ITEM_NODE)
		{
			CTibiaTreeItemData* data = (CTibiaTreeItemData*)(child->data);
			char buf[512];

			int id                = data->GetId();
			int type              = data->GetItemType();
			bool looted           = data->IsLooted();
			DOMElement*  itemElem = doc->createElement(XMLString::transcode("item"));
			itemElem->setAttribute(XMLString::transcode("name"), XMLString::transcode(data->GetName()));
			sprintf(buf, "0x%x", id);
			itemElem->setAttribute(XMLString::transcode("id"), XMLString::transcode(buf));
			sprintf(buf, "%d", looted ? 1 : 0);
			itemElem->setAttribute(XMLString::transcode("looted"), XMLString::transcode(buf));
			sprintf(buf, "%d", type);
			itemElem->setAttribute(XMLString::transcode("type"), XMLString::transcode(buf));
			node->appendChild(itemElem);
		}
	}
}
开发者ID:ArthurRTz,项目名称:tibiaauto,代码行数:35,代码来源:TibiaItem.cpp

示例5: stampDocument

// 2006/12/16
void stampDocument(DOMElement* root) {
  DOMElement* meta = NULL;
  DOMElement* macastamps = NULL;
  DOMElement* stamp = NULL;

  stamp = (root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamp"));
  stamp->setAttribute(XMLString::transcode("module"),
                      XMLString::transcode(_INSTALLED_NAME_));
  stamp->setAttribute(XMLString::transcode("version"),
                      XMLString::transcode(_VERSION_));
  stamp->setAttribute(XMLString::transcode("timestamp"),
                      XMLString::transcode(getTimestamp().c_str()));

  DOMNodeList* metaList = root->getElementsByTagName(XMLString::transcode("meta"));
  if (metaList->getLength() == 0) { // NO meta Element
    meta = (root->getOwnerDocument())->createElement(XMLString::transcode("meta"));
    macastamps =
      (root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamps"));
    meta->appendChild(macastamps);
    root->insertBefore(meta,root->getFirstChild());
  } else { // meta Element
    meta = (DOMElement*)metaList->item(0);
    DOMNodeList* macastampsList = 
      meta->getElementsByTagName(XMLString::transcode("maca_stamps"));
    if (macastampsList->getLength() == 0) { // NO macastamps Element
      macastamps =
        (root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamps"));
      meta->appendChild(macastamps);
    } else { // macastamps Element
      macastamps = (DOMElement*)macastampsList->item(0);
    }
  }
  macastamps->appendChild(stamp);
}
开发者ID:lgwizme,项目名称:macaon,代码行数:35,代码来源:main.cpp

示例6: AddBlankReportTable

/*
 * Add an empty table (required by the DTD).
 */
static void AddBlankReportTable(DOMDocument* doc, DOMElement* parentElement)
{
    DOMElement* element = doc->createElement(ToXMLCh(REPORT_RESULTS_ELEMENT_NAME));
    element->setAttribute(ToXMLCh(NAME_ATTRIBUTE), ToXMLCh("NA"));
    element->setAttribute(ToXMLCh(ROWS_ATTRIBUTE), ToXMLCh("0"));
    element->setAttribute(ToXMLCh(COLS_ATTRIBUTE), ToXMLCh("0"));
    parentElement->appendChild(element);
}
开发者ID:HenrikBengtsson,项目名称:Affx-Fusion-SDK,代码行数:11,代码来源:GQCFileData.cpp

示例7: ToXMLCh

/* Create a root element */
static DOMElement *CreateGenericReportElement(DOMDocument* doc)
{
    DOMElement* element = doc->createElement(ToXMLCh(GENERIC_REPORT_ELEMENT_NAME));
    element->setAttribute(ToXMLCh(TYPE_ATTRIBUTE), ToXMLCh(REPORT_TYPE));
    element->setAttribute(ToXMLCh(TITLE_ATTRIBUTE), ToXMLCh(REPORT_TITLE));
    DateTime now = DateTime::GetCurrentDateTime();
    element->setAttribute(ToXMLCh(DATE_ATTRIBUTE), ToXMLCh(now.ToString()));
    return element;
}
开发者ID:HenrikBengtsson,项目名称:Affx-Fusion-SDK,代码行数:10,代码来源:GQCFileData.cpp

示例8: appendEntityChildren

void EntityXMLFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, const World* world, EntityID entity)
{
    using namespace xercesc;
    DOMDocument* doc = parentElement->getOwnerDocument();

    auto childrenRange = world->GetEntityChildren().equal_range(entity);
    for (auto it = childrenRange.first; it != childrenRange.second; ++it) {
        EntityID childEntity = it->second;

        DOMElement* entityElement = doc->createElement(X("Entity"));
        const std::string& name = world->GetName(childEntity);
        if (!name.empty()) {
            entityElement->setAttribute(X("name"), X(name));
        }
        parentElement->appendChild(entityElement);

        DOMElement* componentsElement = doc->createElement(X("Components"));
        entityElement->appendChild(componentsElement);
        appentEntityComponents(componentsElement, world, childEntity);

        DOMElement* childrenElement = doc->createElement(X("Children"));
        entityElement->appendChild(childrenElement);
        appendEntityChildren(childrenElement, world, childEntity);
    }
}
开发者ID:FakeShemp,项目名称:TacticalZ,代码行数:25,代码来源:EntityXMLFileWriter.cpp

示例9: createConfigElement

void Triggerconf::createConfigElement (string module, string submodule, string configname)
{
	if (rootnode == NULL) return;
	
	if (existsConfigElement (module, submodule, configname)) {
		resetError ();	
		return;
	}

	DOMNode* currentSubmodule = selectSubmodule (module, submodule);
	if (currentSubmodule == NULL) return;

	XMLCh* xitemname	= XMLString::transcode (ELEMENT_CONFIGITEM_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xitemname);
	XMLString::release	(&xitemname);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xconfigname	= XMLString::transcode (configname.c_str ());
	node->setAttribute	(xattrname, xconfigname);
	XMLString::release	(&xattrname);
	XMLString::release	(&xconfigname);

	currentSubmodule->appendChild (node);

	resetError ();
}
开发者ID:freshbob,项目名称:worms-attack,代码行数:26,代码来源:triggerconf.cpp

示例10: createSubmodule

void Triggerconf::createSubmodule (string module, string submodule)
{
	if (rootnode == NULL) return;
	
	if (existsSubmodule (module, submodule)) {
		resetError ();	
		return;
	}

	DOMNode* currentModule	= selectModule (module);
	if (currentModule == NULL) return;
	
	XMLCh* xsubmodule	= XMLString::transcode (ELEMENT_SUBMODULE_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xsubmodule);
	XMLString::release	(&xsubmodule);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xsubmodulename	= XMLString::transcode (submodule.c_str ());
	node->setAttribute	(xattrname, xsubmodulename);
	XMLString::release	(&xattrname);
	XMLString::release	(&xsubmodulename);

	currentModule->appendChild (node);

	resetError ();
}
开发者ID:freshbob,项目名称:worms-attack,代码行数:26,代码来源:triggerconf.cpp

示例11: appendElementWithText

void appendElementWithText( DOMNode* cur, DOMNode* reply,
                            const char* name, const char* text,
                            int indentLevel, bool indent,
                            attrVect* attribute ) {

   MC2String indentStr( indentLevel*3, ' ' );
   indentStr.insert( 0, "\n" );   
   DOMDocument* doc = XMLTool::getOwner( reply );
   DOMElement* textElement = doc->createElement( X( name ) );
   if ( text != NULL ) {
      textElement->appendChild( doc->createTextNode( X( text ) ) );
   }

   if ( attribute != NULL ) {
      for ( uint32 i = 0 ; i < attribute->size() ; ++i ) {
         textElement->setAttribute( X( (*attribute)[ i ].first ), 
                                    X( (*attribute)[ i ].second ) );
      }
   }

   // Add textElement to cur
   if ( indent ) {
      cur->appendChild( doc->createTextNode( X( indentStr.c_str() ) ) );
   }
   cur->appendChild( textElement );
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:26,代码来源:XMLServerElements.cpp

示例12:

void ILI2Handler::startElement(
    CPL_UNUSED const XMLCh* const uri,
    CPL_UNUSED const XMLCh* const localname,
    const XMLCh* const qname,
    const Attributes& attrs
    ) {
  // start to add the layers, features with the DATASECTION
  char *tmpC = NULL;
  m_nEntityCounter = 0;
  if ((level >= 0) || (cmpStr(ILI2_DATASECTION, tmpC = XMLString::transcode(qname)) == 0)) {
    level++;

    if (level >= 2) {

      // create the dom tree
      DOMElement *elem = (DOMElement*)dom_doc->createElement(qname);
      
      // add all attributes
      unsigned int len = attrs.getLength();
      for (unsigned int index = 0; index < len; index++)
        elem->setAttribute(attrs.getQName(index), attrs.getValue(index));
      dom_elem->appendChild(elem);
      dom_elem = elem;
    }
  }
  XMLString::release(&tmpC);
}
开发者ID:garnertb,项目名称:gdal,代码行数:27,代码来源:ili2handler.cpp

示例13: toXML

DOMElement* EppAuthInfo::toXML( DOMDocument& doc, const DOMString& tag )
{
	DOMElement* body = doc.createElement(tag);
	DOMElement* elm;
	if( (type.isNotNull()) && type.equals(TYPE_PW) )
	{
		elm = doc.createElement(XS("pw"));
		body->appendChild(elm);
		if( roid.isNotNull() && roid.length() > 0 )
		{
			elm->setAttribute(XS("roid"), roid);
		}
		if( value.isNotNull() )
		{
			elm->appendChild(doc.createTextNode(value));
		}
	}
	else if( (type.isNotNull()) && type.equals(TYPE_EXT) )
	{
		elm = doc.createElement(XS("ext"));
		body->appendChild(elm);
	}

	return body;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:25,代码来源:EppAuthInfo.cpp

示例14: SaveFileTreeToXML

XERCES_CPP_NAMESPACE_USE

	
void SaveFileTreeToXML(const XMLCh* RootPath, DOMNode* RootNode, XERCES_CPP_NAMESPACE::DOMDocument* Document)
{
	WIN32_FIND_DATA FindData;
	ZeroMemory( &FindData, sizeof(WIN32_FIND_DATA));
	XMLSize_t SearchPatternLen = XMLString::stringLen( RootPath ) + 1 +  1;
	XMLCh* SearchPattern = new XMLCh[SearchPatternLen];
	ZeroMemory(SearchPattern, sizeof(XMLCh)*SearchPatternLen );
	XMLString::catString( SearchPattern, RootPath );
	XMLString::catString( SearchPattern, L"*");
	
	HANDLE hSearch = FindFirstFile(SearchPattern, &FindData);
	delete[] SearchPattern;
	if( INVALID_HANDLE_VALUE == hSearch )
		return;
	do
	{
		XMLCh* FileName = FindData.cFileName;
		if( FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
		{
			if( (XMLString::compareIString(FileName,L".")!=0) &&
				(XMLString::compareIString(FileName,L"..")!=0) )
			{
				DOMElement* dir = Document->createElement(L"directory");
				dir->setAttribute(L"name", FileName );
				RootNode->appendChild(dir);
				XMLSize_t SubDirPathLen = XMLString::stringLen( RootPath ) + XMLString::stringLen( FileName ) + 1  + 1;
				XMLCh* SubDir = new XMLCh[ SubDirPathLen ];
				ZeroMemory( SubDir, sizeof(XMLCh)*SubDirPathLen );
				XMLString::catString( SubDir, RootPath );
				XMLString::catString( SubDir, FileName);
				XMLString::catString( SubDir, L"\\" );
				SaveFileTreeToXML( SubDir, dir, Document );
				delete[] SubDir;
			}
		}
		else
		{
			DOMElement* file = Document->createElement(L"file");
			file->setAttribute(L"name", FileName );
			RootNode->appendChild(file);
		}
	}while( FindNextFile( hSearch, &FindData) != 0 );
	FindClose( hSearch );
}
开发者ID:Letractively,项目名称:koritools,代码行数:47,代码来源:filetree2xml.cpp

示例15:

xercesc::DOMElement *XCube::recursiveXML(xercesc::DOMDocument* doc)
{
	DOMElement *cubeElem = doc->createElement(XMLString::transcode("Cube"));

	if(this->_name != "")
		cubeElem->setAttribute(XMLString::transcode("name"),XMLString::transcode(this->_name.c_str()));
	if(this->_fact != "")
		cubeElem->setAttribute(XMLString::transcode("tablename"),XMLString::transcode(this->_fact.c_str()));

	if(this->_dimensions.size() > 0)
	{
		Dimension *tempdimension;
		for(int i = 0;i < this->_dimensions.size() ;i++)
		{
			tempdimension = this->getDimension(_dimensions[i]->getName());
			cubeElem->appendChild(tempdimension->recursiveXML(doc));

		}

	}

	if(this->_measures.size() > 0)
	{
		Measure *tempMeasures;
		for(int i = 0;i < this->_measures.size() ;i++)
		{
			tempMeasures = this->getMeasure(_measures[i]->getName());
			cubeElem->appendChild(tempMeasures->recursiveXML(doc));

		}

	}

	if(this->_calcmembers.size() > 0)
	{
		calcMember *tempCalcmember;
		for(int i = 0;i < this->_calcmembers.size() ;i++)
		{
			tempCalcmember = this->getCalMember(_calcmembers[i]->getName());
			cubeElem->appendChild(tempCalcmember->recursiveXML(doc));

		}

	}

	return cubeElem;
}
开发者ID:mydw,项目名称:mydw,代码行数:47,代码来源:XCube.cpp


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