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


C++ DOMDocument类代码示例

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


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

示例1:

DOMElement * DSIGObject::createBlankObject(void) {

	safeBuffer str;
	const XMLCh * prefix;
	DOMDocument *doc = mp_env->getParentDocument();

	prefix = mp_env->getDSIGNSPrefix();
	
	// Create the transform node
	makeQName(str, prefix, s_Object);
	mp_objectNode = doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());

	mp_idAttr = NULL;
	mp_mimeTypeAttr = NULL;
	mp_encodingAttr = NULL;

	return (DOMElement *) mp_objectNode;

}
开发者ID:okean,项目名称:cpputils,代码行数:19,代码来源:DSIGObject.cpp

示例2:

DOMElement * DSIGTransformEnvelope::createBlankTransform(DOMDocument * parentDoc) {

	safeBuffer str;
	const XMLCh * prefix;
	DOMElement *ret;
	DOMDocument *doc = mp_env->getParentDocument();

	prefix = mp_env->getDSIGNSPrefix();
	
	// Create the transform node
	makeQName(str, prefix, "Transform");
	ret = doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
	ret->setAttributeNS(NULL,DSIGConstants::s_unicodeStrAlgorithm, DSIGConstants::s_unicodeStrURIENVELOPE);

	mp_txfmNode = ret;

	return ret;

}
开发者ID:okean,项目名称:cpputils,代码行数:19,代码来源:DSIGTransformEnvelope.cpp

示例3:

DOMElement * XKMSAuthenticationImpl::createBlankAuthentication(const XMLCh * id) {

	// Get some setup values
	safeBuffer str;
	DOMDocument *doc = mp_env->getParentDocument();
	const XMLCh * prefix = mp_env->getXKMSNSPrefix();

	makeQName(str, prefix, XKMSConstants::s_tagAuthentication);

	mp_authenticationElement = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS, 
												str.rawXMLChBuffer());

	mp_env->doPrettyPrint(mp_authenticationElement);

	// This isn't used immediately - it is simply held for when we create a signature
	mp_keyBindingId = id;

	return mp_authenticationElement;

}
开发者ID:okean,项目名称:cpputils,代码行数:20,代码来源:XKMSAuthenticationImpl.cpp

示例4: XML

/*
	\brief It accepts a XML (ascii) buffer and it parses it.

	This function is used when we have a char buffer containing an XML fragment, and we have to parse it.
	This function returns the list of PSML items (<section>) contained in the XML buffer.

	\param Buffer: pointer to a buffer that contains the XML fragment (in ascii).
	\param BufSize: number of valid bytes in the previous buffer; not NULL terminated buffers are supported as well.

	\return A pointer to the list of <section> nodes contained into the XML fragment if everything
	is fine, NULL otherwise.
	In case of error, the error message can be retrieved by the GetLastError() method.
*/
DOMNodeList *CPSMLReader::ParseMemBuf(char *Buffer, int BytesToParse)
{
DOMDocument *Document;
XMLCh TempBuffer[NETPDL_MAX_STRING + 1];
MemBufInputSource MemBuf( (const XMLByte *) Buffer, BytesToParse, "", false);

	try
	{
		// Reset any other document previously created
		m_DOMParser->resetDocumentPool();

		// Load the description in memory and get document root
		m_DOMParser->parse(MemBuf);

		Document= m_DOMParser->getDocument();

		if ( (Document->getDocumentElement()) == NULL)
		{
			errorsnprintf(__FILE__, __FUNCTION__, __LINE__, m_errbuf, sizeof(m_errbuf),
				"Fatal error: cannot parse PSML file. Possible errors: "
				"wrong file location, or not well-formed XML file.");
			return NULL;
		}
	}
	catch (...)
	{
		errorsnprintf(__FILE__, __FUNCTION__, __LINE__, m_errbuf, sizeof(m_errbuf), "Unexpected exception during PSML buffer parsing.");
		return NULL;
	}

	if (Document == NULL)
	{
		errorsnprintf(__FILE__, __FUNCTION__, __LINE__, m_errbuf, sizeof(m_errbuf), "Unexpected exception during PSML buffer parsing.");
		return NULL;
	}

	XMLString::transcode(PSML_SECTION, TempBuffer, NETPDL_MAX_STRING);

	// After parsing the '<packet>' fragment, let's list the <section> contained into it
	return Document->getElementsByTagName(TempBuffer);
}
开发者ID:AshleyPeterson,项目名称:netbee-lite,代码行数:54,代码来源:psmlreader.cpp

示例5: XSECException

DSIGSignature * XKMSAuthenticationImpl::addKeyBindingAuthenticationSignature(
		canonicalizationMethod cm,
		signatureMethod	sm,
		hashMethod hm) {

	if (mp_keyBindingId == NULL) {
		throw XSECException(XSECException::XKMSError,
			"XKMSAuthenticationImpl::addKeyBindingAuthenticationSignature - called prior to key infos being added");
	}

	DSIGSignature * ret = m_prov.newSignature();
	DOMElement * elt = ret->createBlankSignature(mp_env->getParentDocument(), cm, sm, hm);

	/* Create the enveloping reference */
	safeBuffer sb;
	sb.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
	sb.sbXMLChAppendCh(chPound);
	sb.sbXMLChCat(mp_keyBindingId);

	DSIGReference *ref = ret->createReference(sb.rawXMLChBuffer());
	ref->appendCanonicalizationTransform(CANON_C14NE_COM);

	/* Embed the signature in the document inside a KeyBindingAuthentication element */
	safeBuffer str;
	DOMDocument *doc = mp_env->getParentDocument();
	const XMLCh * prefix = mp_env->getXKMSNSPrefix();

	makeQName(str, prefix, XKMSConstants::s_tagKeyBindingAuthentication);

	DOMElement * t = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS, 
												str.rawXMLChBuffer());

	mp_env->doPrettyPrint(t);
	t->appendChild(elt);
	mp_env->doPrettyPrint(t);

	mp_authenticationElement->appendChild(t);
	mp_env->doPrettyPrint(mp_authenticationElement);

	return ret;
}
开发者ID:okean,项目名称:cpputils,代码行数:41,代码来源:XKMSAuthenticationImpl.cpp

示例6: DOMHTMLDocument

IDOMDocument* DOMDocument::createInstance(WebCore::Document* d)
{
    if (!d)
        return 0;

    HRESULT hr;
    IDOMDocument* domDocument = 0;

    if (d->isHTMLDocument()) {
        DOMHTMLDocument* newDocument = new DOMHTMLDocument(d);
        hr = newDocument->QueryInterface(IID_IDOMDocument, (void**)&domDocument);
    } else {
        DOMDocument* newDocument = new DOMDocument(d);
        hr = newDocument->QueryInterface(IID_IDOMDocument, (void**)&domDocument);
    }

    if (FAILED(hr))
        return 0;

    return domDocument;
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:21,代码来源:DOMCoreClasses.cpp

示例7: getAttribute

bool ConfigurationFileHandler::getAttribute(std::string algorithm, std::string attribute, int* result) {
#ifdef BRICS_XERCES_ENABLE
	if (errorsOccured) {
		return false;
	}

    DOMNode* current = NULL;
    DOMNode* attributeNode = NULL;
    XMLCh* algorithmName = XMLString::transcode(algorithm.c_str());
    XMLCh* attributeName = XMLString::transcode(attribute.c_str());
    string tmpResult;
    bool attributeFound = false;

    DOMDocument* doc = parser->getDocument();
    DOMNodeList* root = doc->getElementsByTagName(algorithmName);
    if (root->getLength() > 1) {
    	LOG(WARNING) << "More than one " << algorithm << " found, taking the first one";
    } else if(root->getLength() < 1) {
    	LOG(WARNING) << "No algorithm called " << algorithm << " found.";
		return false; //TODO release resouces
    }

    current = root->item(0);
    DOMNamedNodeMap* attributesList =  current->getAttributes();
    attributeNode = attributesList->getNamedItem(attributeName);

    if (attributeNode != 0) {
		    tmpResult = XMLString::transcode(attributeNode->getNodeValue());
		    *result = atoi(tmpResult.c_str());
		    attributeFound = true;
	}

    XMLString::release(&algorithmName);
    XMLString::release(&attributeName);

    return attributeFound;
#else
    return false;
#endif
}
开发者ID:brics,项目名称:brics_3d,代码行数:40,代码来源:ConfigurationFileHandler.cpp

示例8: set_element_value

//
// set_element_value
//
void Utils::
set_element_value (xercesc::DOMElement * e,
                   const GAME::Xml::String & element,
                   const GAME::Xml::String & value)
{
  using xercesc::DOMNode;
  using xercesc::DOMNodeList;
  using xercesc::DOMDocument;

  // There should be only 1 <name> tag in the list.
  GAME::Xml::String nodename;
  DOMNode * node = 0;
  DOMNodeList * list = e->getChildNodes ();
  size_t len = list->getLength ();

  for (size_t i = 0; i < len; ++ i)
  {
    // Get the name of the next node.
    node = list->item (i);
    nodename.set (node->getNodeName (), false);

    if (nodename == element)
      break;

    // Reset the node.
    node = 0;
  }

  if (node == 0)
  {
    // We need to create the <name> element.
    DOMDocument * doc = e->getOwnerDocument ();
    node = doc->createElement (element);
    e->appendChild (node);
  }

  // Since there are no child nodes, we can just set the
  // text content to the name of the object.
  node->setTextContent (value);
}
开发者ID:SEDS,项目名称:GAME,代码行数:43,代码来源:XME_Utils.cpp

示例9: setOAEPparams

void XENCEncryptionMethodImpl::setOAEPparams(const XMLCh * params) {

	if (mp_oaepParamsTextNode == NULL) {

		// Need to create
		if (mp_mgfAlgorithmAttr == NULL && mp_digestAlgorithmAttr == NULL && mp_keySizeTextNode == NULL) {
			mp_env->doPrettyPrint(mp_encryptionMethodElement);
		}

		// Get some setup values
		safeBuffer str;
		DOMDocument *doc = mp_env->getParentDocument();
		const XMLCh * prefix = mp_env->getXENCNSPrefix();

		makeQName(str, prefix, s_OAEPparams);

        DOMNode* inspoint = NULL;
		DOMElement *e = doc->createElementNS(DSIGConstants::s_unicodeStrURIXENC, str.rawXMLChBuffer());
        if (mp_keySizeTextNode != NULL) {
            inspoint = mp_keySizeTextNode->getParentNode()->getNextSibling();
        }
        else {
            inspoint = mp_encryptionMethodElement->getFirstChild();
        }

        mp_encryptionMethodElement->insertBefore(e, inspoint);
		mp_env->doPrettyPrint(mp_encryptionMethodElement);

		e->appendChild(mp_oaepParamsTextNode = doc->createTextNode(params));

	} 
	
	else {

		mp_oaepParamsTextNode->setNodeValue(params);

	}

}
开发者ID:okean,项目名称:cpputils,代码行数:39,代码来源:XENCEncryptionMethodImpl.cpp

示例10: XS

PerfPart::PerfPart( PMLDocument *doc, ScorePart *part ){
    m_doc = doc;

    DOMDocument *domdoc = part->getElement()->getOwnerDocument();
    m_scorePart = part;
    m_element = domdoc->createElement( XS("perfpart") );       //'perfpart' tag is the m_element for this class

  //create part attribute
    m_element->setAttribute( XS("part"), XS( m_scorePart->getID().c_str() ) );
  
  //append part to performance element
    DOMElement *perf = (DOMElement*)domdoc->getElementsByTagName(XS("performance"))->item(0);
    perf->appendChild( m_element );

    DOMNodeList *nl = m_element->getElementsByTagName(XS(PNote::Tag));

    for( int i=0; i<nl->getLength(); i++ ){
        m_notes.push_back( new PNote( m_doc, (DOMElement*)nl->item(i) ) );

    }

}
开发者ID:jmacritchie,项目名称:DougMatcher,代码行数:22,代码来源:perfpart.cpp

示例11: align

void SNote::align( PNote *note, bool correct ){

    DOMNodeList *list = m_element->getElementsByTagName(XS("align"));
    DOMElement *align;

    if( list->getLength() == 0 ){
        DOMDocument *doc = m_element->getOwnerDocument();
        align = doc->createElement(XS("align"));
        m_element->appendChild(align);
    }
    else{
        align = (DOMElement*)list->item(0);
    }


    align->setAttribute( XS("note"), XS(note->getID().c_str()) );
		       
    if( correct )
        setText( align, "correct" );
    else
        setText( align, "wrong" );
}
开发者ID:jmacritchie,项目名称:DougMatcher,代码行数:22,代码来源:snote.cpp

示例12: LoadException

/**
 * TODO: JavaDocs
 *
 * @throws LoadException
 */
ConnectionTemplate *XMLConnectionTemplateLoader::loadConnectionTemplate(
		istream &inStream) const {
	DOMDocument *document;
	try {
		document = Utils::DOM::parseDocumentFromStream(inStream);
		document->normalizeDocument();
		removeWhitespaceTextNodes(document->getDocumentElement());
	} catch (const DOMParseException &ex) {
		throw LoadException("XMLException, see above");
	}

	try {
		XMLConnectionTemplate *result = new XMLConnectionTemplate();
		result->fromXML(document->getDocumentElement());
		return result;
	} catch (const XMLReadable::XMLSerializationException &ex) {
		Log::error(LOG_LOCATION("XMLConnectionTemplateLoader",
			"loadConnectionTemplate"), 
			"Got XMLSerializationException while creating "
			"template...");
		throw LoadException(ex.what());
	}
}
开发者ID:BackupTheBerlios,项目名称:kinneret-svn,代码行数:28,代码来源:XMLConnectionTemplateLoader.cpp

示例13: XML

/*
	\brief It accepts a XML (ascii) buffer and it parses it.

	This function is used when we have a char buffer containing an XML fragment, and we have to parse it.
	This function returns the list of PDML items (&lt;section&gt;) contained in the XML buffer.

	\param Buffer: pointer to a buffer that contains the XML fragment (in ascii).
	\param BytesToParse: number of valid bytes in the previous buffer; not NULL terminated buffers are supported as well.

	\return A pointer to the DOM document associated to the XML fragment if
	everything is fine, NULL otherwise.
	In case of error, the error message can be retrieved by the GetLastError() method.
*/
DOMDocument* CPDMLReader::ParseMemBuf(char *Buffer, int BytesToParse)
{
DOMDocument *Document;
MemBufInputSource MemBuf( (const XMLByte *) Buffer, BytesToParse, "", false);

	try
	{
		// Reset any other document previously created
		m_DOMParser->resetDocumentPool();

		// Load the description in memory and get document root
		m_DOMParser->parse(MemBuf);

		Document= m_DOMParser->getDocument();

		if ( (Document->getDocumentElement()) == NULL)
		{
			errorsnprintf(__FILE__, __FUNCTION__, __LINE__, m_errbuf, sizeof(m_errbuf),
				"Fatal error: cannot parse PDML file. Possible errors: "
				"wrong file location, or not well-formed XML file.");
			return NULL;
		}
	}
	catch (...)
	{
		errorsnprintf(__FILE__, __FUNCTION__, __LINE__, m_errbuf, sizeof(m_errbuf), "Unexpected exception during PDML buffer parsing.");
		return NULL;
	}

	if (Document == NULL)
	{
		errorsnprintf(__FILE__, __FUNCTION__, __LINE__, m_errbuf, sizeof(m_errbuf), "Unexpected exception during PDML buffer parsing.");
		return NULL;
	}

	return Document;
}
开发者ID:gerpe,项目名称:fresdwn,代码行数:50,代码来源:pdmlreader.cpp

示例14: new

// XSAnnotation methods
void XSAnnotation::writeAnnotation(DOMNode* node, ANNOTATION_TARGET targetType)
{
    XercesDOMParser *parser = new (fMemoryManager) XercesDOMParser(0, fMemoryManager);
    parser->setDoNamespaces(true);
    parser->setValidationScheme(XercesDOMParser::Val_Never);
    
    DOMDocument* futureOwner = (targetType == W3C_DOM_ELEMENT) ?
        ((DOMElement*)node)->getOwnerDocument() :
        (DOMDocument*)node;

    MemBufInputSource* memBufIS = new (fMemoryManager) MemBufInputSource
    (
        (const XMLByte*)fContents
        , XMLString::stringLen(fContents)*sizeof(XMLCh)
        , ""
        , false
        , fMemoryManager
    );
    memBufIS->setEncoding(XMLUni::fgXMLChEncodingString);
    memBufIS->setCopyBufToStream(false);

    try
    {        
        parser->parse(*memBufIS);
    }
    catch (const XMLException&)
    {
        // REVISIT:  should we really eat this?
    }

    DOMNode* newElem = futureOwner->importNode((parser->getDocument())->getDocumentElement(), true);
    node->insertBefore(newElem, node->getFirstChild());

    delete parser;
    delete memBufIS;
}
开发者ID:mydw,项目名称:mydw,代码行数:37,代码来源:XSAnnotation.cpp

示例15: str

saml2::Assertion *
gss_eap_saml_assertion_provider::parseAssertion(const gss_buffer_t buffer)
{
    string str((char *)buffer->value, buffer->length);
    istringstream istream(str);
    DOMDocument *doc;
    const XMLObjectBuilder *b;

    try {
        doc = XMLToolingConfig::getConfig().getParser().parse(istream);
        if (doc == NULL)
            return NULL;

        b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());

#ifdef __APPLE__
        return (saml2::Assertion *)((void *)b->buildFromDocument(doc));
#else
        return dynamic_cast<saml2::Assertion *>(b->buildFromDocument(doc));
#endif
    } catch (exception &e) {
        return NULL;
    }
}
开发者ID:janetuk,项目名称:mech_eap,代码行数:24,代码来源:util_saml.cpp


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