本文整理汇总了C++中DOMDocument::getFirstChild方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMDocument::getFirstChild方法的具体用法?C++ DOMDocument::getFirstChild怎么用?C++ DOMDocument::getFirstChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::getFirstChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StrX
bool Module::WriteStaticXML (const string& xml_file) {
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(StrX("Core").XMLchar() );
if (impl==NULL) return false;
DOMDocument* doc = impl->createDocument( 0, StrX("PARAM").XMLchar(), 0);
DOMNode* topnode = doc->getFirstChild();
Parameters* parameters = m_seq_tree->GetParameters();
DOMNode* backup_node = parameters->GetNode();
XMLIO* xmlio = new XMLIO();
parameters->SetNode(topnode);
parameters->AddAllDOMattributes(false);
if ( ((DOMElement*) topnode)->getAttributeNode(StrX("Name").XMLchar()) != NULL)
((DOMElement*) topnode)->removeAttribute (StrX("Name").XMLchar());
parameters->SetNode(backup_node);
//recursively add elements
if (!StaticDOM(doc,topnode)) return false;
xmlio->Write (impl, topnode, xml_file);
delete doc;
delete topnode;
delete parameters;
delete backup_node;
delete xmlio;
return true;
}
示例2: if
// ---------------------------------------------------------------------------
// This method assumes that currentNode is an xinclude element and parses
// it accordingly, acting on what it finds.
// ---------------------------------------------------------------------------
bool
XIncludeUtils::doDOMNodeXInclude(DOMNode *xincludeNode, DOMDocument *parsedDocument, XMLEntityHandler* entityResolver){
bool modifiedNode = false;
/* the relevant attributes to look for */
const XMLCh *href = NULL;
const XMLCh *parse = NULL;
const XMLCh *xpointer = NULL;
const XMLCh *encoding = NULL;
const XMLCh *accept = NULL;
const XMLCh *acceptlanguage = NULL;
DOMNode *includeParent = xincludeNode->getParentNode();
if(xincludeNode->hasAttributes()) {
/* get all the attributes of the node */
DOMNamedNodeMap *pAttributes = xincludeNode->getAttributes();
XMLSize_t nSize = pAttributes->getLength();
for(XMLSize_t i=0;i<nSize;++i) {
DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
const XMLCh *attrName = pAttributeNode->getName();
/* check each attribute against the potential useful names */
if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeHREFAttrName)){
href = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeParseAttrName)){
parse = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeXPointerAttrName)){
xpointer = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeEncodingAttrName)){
encoding = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptAttrName)){
accept = pAttributeNode->getValue();
} else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptLanguageAttrName)){
acceptlanguage = pAttributeNode->getValue();
} else {
/* if any other attribute is in the xi namespace, it's an error */
const XMLCh *attrNamespaceURI = pAttributeNode->getNamespaceURI();
if (attrNamespaceURI && XMLString::equals(attrNamespaceURI, XIncludeUtils::fgXIIIncludeNamespaceURI)){
} else {
/* ignore - any other attribute is allowed according to spec,
and must be ignored */
}
}
}
}
// 3.1 xi:include Element
// The children property of the xi:include element may include a single xi:fallback element;
// the appearance of more than one xi:fallback element, an xi:include element,
// or any other element from the XInclude namespace is a fatal error.
DOMNode *child;
DOMElement *fallback = NULL;
for (child = xincludeNode->getFirstChild(); child != 0; child=child->getNextSibling()){
if(child->getNodeType()!=DOMNode::ELEMENT_NODE)
continue;
if ( isXIFallbackDOMNode(child) ){
if (fallback != NULL){
/* fatal error - there are more than one fallback children */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeMultipleFallbackElems,
parsedDocument->getDocumentURI(), parsedDocument->getDocumentURI());
return false;
}
fallback = (DOMElement*)child;
}
else if(isXIIncludeDOMNode(child) || XMLString::equals(child->getNamespaceURI(), XIncludeUtils::fgXIIIncludeNamespaceURI)) {
/* fatal error - an xi element different from xi:fallback is a child of xi:include */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeDisallowedChild,
child->getNodeName(), parsedDocument->getDocumentURI());
return false;
}
}
if (href == NULL){
/* this is an unrecoverable error until we have xpointer support -
if there is an xpointer, the current document is assumed
however, there is no xpointer support yet */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeNoHref,
NULL, parsedDocument->getDocumentURI());
return false;
}
/* set up the accept and accept-language values */
if (accept != NULL){
}
if (parse == NULL){
/* use the default, as specified */
parse = XIncludeUtils::fgXIIncludeParseAttrXMLValue;
}
if (xpointer != NULL){
/* not supported yet */
/* Note that finding an xpointer attr along with parse="text" is a Fatal Error
* - http://www.w3.org/TR/xinclude/#include-location */
XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeXPointerNotSupported,
NULL, href);
return false;
//.........这里部分代码省略.........
示例3: main
//.........这里部分代码省略.........
XMLString::transcode("DocCDataSection", tempStr, 3999);
DOMCDATASection* cdataSec = doc->createCDATASection(tempStr);
E11->appendChild(cdataSec);
XMLString::transcode("DocPI", tempStr, 3999);
XMLCh piStr[] = {chLatin_D, chLatin_o, chLatin_c, chLatin_P, chLatin_I, chNull};
DOMProcessingInstruction* docPI = doc->createProcessingInstruction(piStr, tempStr);
E13->appendChild(docPI);
/*
following are whatToShow types:
SHOW_ALL = 0x0000FFFF,
SHOW_ELEMENT = 0x00000001,
SHOW_ATTRIBUTE = 0x00000002,
SHOW_TEXT = 0x00000004,
SHOW_CDATA_SECTION = 0x00000008,
SHOW_ENTITY_REFERENCE = 0x00000010,
SHOW_ENTITY = 0x00000020,
SHOW_PROCESSING_INSTRUCTION = 0x00000040,
SHOW_COMMENT = 0x00000080,
SHOW_DOCUMENT = 0x00000100,
SHOW_DOCUMENT_TYPE = 0x00000200,
SHOW_DOCUMENT_FRAGMENT = 0x00000400,
SHOW_NOTATION = 0x00000800
*/
////////// NodeIterator Test Cases ////////////////
{
// all node iterating test
DOMNode* node = doc->getFirstChild();
UNUSED(node); // silence warning
unsigned long whatToShow = DOMNodeFilter::SHOW_ALL;
MyFilter* filter = new MyFilter(0);
DOMNodeIterator* iter = ((DOMDocumentTraversal*)doc)->createNodeIterator(root, whatToShow, filter, true);
TASSERT(iter->getWhatToShow() == 65535);
TASSERT(iter->getExpandEntityReferences() == 1);
DOMNode* nd;
nd = iter->nextNode();
TASSERT (nd ==root);
nd = iter->nextNode();
TASSERT (nd ==E11);
nd = iter->nextNode();
TASSERT(nd == textNode1);
nd = iter->nextNode();
TASSERT(nd == E111);
nd = iter->nextNode();
TASSERT(nd == E112);
nd = iter->nextNode();
TASSERT(nd == cdataSec);
nd = iter->nextNode();
TASSERT(nd == E12);
nd = iter->nextNode();
TASSERT(nd == textNode2);
nd = iter->nextNode();
TASSERT(nd == E121);
nd = iter->nextNode();
TASSERT(nd == E122);
nd = iter->nextNode();
TASSERT(nd == E13);
nd = iter->nextNode();