本文整理汇总了C++中DOMElement::release方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::release方法的具体用法?C++ DOMElement::release怎么用?C++ DOMElement::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluate
//.........这里部分代码省略.........
formatTarget->writeChars(buf, read, NULL);
read = bis->readBytes(buf, 1023);
}
}
}
else {
XENCEncryptedData *xenc = NULL;
// Encrypting
if (kek != NULL && key == NULL) {
XSECPlatformUtils::g_cryptoProvider->getRandom(keyBuf, 24);
XSECCryptoSymmetricKey * k =
XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_3DES_192);
k->setKey(keyBuf, 24);
cipher->setKey(k);
keyAlg = ENCRYPT_3DES_CBC;
keyStr = keyBuf;
keyLen = 24;
}
if (encryptFileAsData) {
// Create a BinInputStream
#if defined(XSEC_XERCES_REQUIRES_MEMMGR)
BinFileInputStream * is = new BinFileInputStream(filename, XMLPlatformUtils::fgMemoryManager);
#else
BinFileInputStream * is = new BinFileInputStream(filename);
#endif
xenc = cipher->encryptBinInputStream(is, keyAlg);
// Replace the document element
DOMElement * elt = doc->getDocumentElement();
doc->replaceChild(xenc->getElement(), elt);
elt->release();
}
else {
// Document encryption
cipher->encryptElement(doc->getDocumentElement(), keyAlg);
}
// Do we encrypt a created key?
if (kek != NULL && xenc != NULL) {
XENCEncryptedKey *xkey = cipher->encryptKey(keyStr, keyLen, kekAlg);
// Add to the EncryptedData
xenc->appendEncryptedKey(xkey);
}
}
if (doXMLOutput) {
// Output the result
XMLCh core[] = {
XERCES_CPP_NAMESPACE_QUALIFIER chLatin_C,
XERCES_CPP_NAMESPACE_QUALIFIER chLatin_o,
XERCES_CPP_NAMESPACE_QUALIFIER chLatin_r,
XERCES_CPP_NAMESPACE_QUALIFIER chLatin_e,
XERCES_CPP_NAMESPACE_QUALIFIER chNull
};
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(core);
#if defined (XSEC_XERCES_DOMLSSERIALIZER)
// DOM L3 version as per Xerces 3.0 API
DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
Janitor<DOMLSSerializer> j_theSerializer(theSerializer);
示例2: main
int main( )
{
try {
// Initialize Xerces and retrieve a DOMImplementation;
// specify that you want to use the Load and Save (LS)
// feature
XercesInitializer init;
DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(
fromNative("LS").c_str( )
);
if (impl == 0) {
cout << "couldn't create DOM implementation\n";
return EXIT_FAILURE;
}
// Construct a DOMBuilder to parse animals.xml.
DOMPtr<DOMBuilder> parser =
static_cast<DOMImplementationLS*>(impl)->
createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
// Enable namespaces (not needed in this example)
parser->setFeature(XMLUni::fgDOMNamespaces, true);
// Register an error handler
CircusErrorHandler err;
parser->setErrorHandler(&err);
// Parse animals.xml; you can use a URL here
// instead of a file name
DOMDocument* doc =
parser->parseURI("animals.xml");
// Search for Herby the elephant: first, obtain a pointer
// to the "animalList" element.
DOMElement* animalList = doc->getDocumentElement( );
if (animalList->getTagName( ) != fromNative("animalList")) {
cout << "bad document root: "
<< toNative(animalList->getTagName( ))
<< "\n";
return EXIT_FAILURE;
}
// Next, iterate through the "animal" elements, searching
// for Herby the elephant.
DOMNodeList* animals =
animalList->getElementsByTagName(fromNative("animal").c_str( ));
for ( size_t i = 0,
len = animals->getLength( );
i < len;
++i )
{
DOMElement* animal =
static_cast<DOMElement*>(animals->item(i));
const XMLCh* name = getAnimalName(animal);
if (name != 0 && name == fromNative("Herby")) {
// Found Herby -- remove him from document.
animalList->removeChild(animal);
animal->release( ); // optional.
break;
}
}
// Construct a DOMWriter to save animals.xml.
DOMPtr<DOMWriter> writer =
static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
writer->setErrorHandler(&err);
// Save animals.xml.
LocalFileFormatTarget file("animals.xml");
writer->writeNode(&file, *animalList);
} catch (const SAXException& e) {
cout << "xml error: " << toNative(e.getMessage( )) << "\n";
return EXIT_FAILURE;
} catch (const DOMException& e) {
cout << "xml error: " << toNative(e.getMessage( )) << "\n";
return EXIT_FAILURE;
} catch (const exception& e) {
cout << e.what( ) << "\n";
return EXIT_FAILURE;
}
}