本文整理汇总了C++中DOMElement::setNodeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::setNodeValue方法的具体用法?C++ DOMElement::setNodeValue怎么用?C++ DOMElement::setNodeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::setNodeValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/**
* Main routine that utilizes Xercesc module to create a DOM object in memory
* and prints out the resultant DOM structure
* @param argC number of command line args
* @param argV name of command line args
* @return 0 if no errors occurred
*/
int main(int argC, char*argv[]) {
// Initialize the XML4C2 system.
try {
XMLPlatformUtils::Initialize();
} catch (const XMLException& toCatch) {
char *pMsg = XMLString::transcode(toCatch.getMessage());
XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n" << " Exception message:" << pMsg;
XMLString::release(&pMsg);
return 1;
}
// Watch for special case help request
int errorCode = 0;
if (argC > 1) {
XERCES_STD_QUALIFIER
cout << "\nUsage:\n"
" CreateDOMDocument\n\n"
"This program creates a new DOM document from scratch in memory.\n"
"It then prints the count of elements in the tree.\n" << XERCES_STD_QUALIFIER
endl;
errorCode = 1;
}
if (errorCode) {
XMLPlatformUtils::Terminate();
return errorCode;
}
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core"));
if (impl != NULL) {
try {
// create a DomDocument instance
DOMDocument* doc = impl->createDocument(
0, // root element namespace URI.
X("TheHood"), // root element name
0); // document type object (DTD).
// create root attribute nodes
DOMAttr* woop_atr = doc->createAttribute(X("WOOP"));
woop_atr->setValue(X("DANG"));
DOMAttr* fiyah_atr = doc->createAttribute(X("FIYAH"));
fiyah_atr->setValue(X("hot"));
DOMAttr* hungry_atr = doc->createAttribute(X("hungry"));
hungry_atr->setValue(X("starving"));
// create root element
DOMElement* rootElem = doc->getDocumentElement();
// set root attrs
rootElem->setAttributeNode(woop_atr);
rootElem->setAttributeNode(fiyah_atr);
rootElem->setAttributeNode(hungry_atr);
//create root child elements
DOMElement* gangElem = doc->createElement(X("gang"));
rootElem->appendChild(gangElem);
DOMText* gangDataVal = doc->createTextNode(X("YoungThugz"));
gangElem->appendChild(gangDataVal);
gangElem->setAttribute(X("hardness"), X("rock"));
//create gang attr nodes
DOMAttr* members_atr = doc->createAttribute(X("members"));
members_atr->setValue(X("500"));
DOMAttr* color_atr = doc->createAttribute(X("color"));
color_atr->setValue(X("magenta"));
// set gang attr
gangElem->setAttributeNode(members_atr);
gangElem->setAttributeNode(color_atr);
// create gang elem children
DOMElement* piruElem = doc->createElement(X("piru"));
piruElem->setNodeValue(X("w"));
DOMElement* cripElem = doc->createElement(X("crip"));
cripElem->setNodeValue(X("t"));
DOMElement* trgElem = doc->createElement(X("trg"));
trgElem->setNodeValue(X("o"));
// append gang elem children
gangElem->appendChild(piruElem);
gangElem->appendChild(cripElem);
gangElem->appendChild(trgElem);
DOMElement* turfElem = doc->createElement(X("turf"));
rootElem->appendChild(turfElem);
turfElem->setAttribute(X("idea"), X("great"));
DOMText* turfDataVal = doc->createTextNode(X("West Side Projects"));
turfElem->appendChild(turfDataVal);
DOMElement* cliqueElem = doc->createElement(X("clique"));
rootElem->appendChild(cliqueElem);
DOMText* cliqueDataVal = doc->createTextNode(X("Balla$"));
cliqueElem->appendChild(cliqueDataVal);
cliqueElem->setAttribute(X("Comradery"), X("tight"));
DOMElement* sideElem = doc->createElement(X("side"));
//.........这里部分代码省略.........