本文整理汇总了C++中DOMNode::getFirstChild方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMNode::getFirstChild方法的具体用法?C++ DOMNode::getFirstChild怎么用?C++ DOMNode::getFirstChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::getFirstChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTextContent
void DOMNodeImpl::setTextContent(const XMLCh* textContent){
DOMNode *thisNode = castToNode(this);
switch (thisNode->getNodeType())
{
case DOMNode::ELEMENT_NODE:
case DOMNode::ENTITY_NODE:
case DOMNode::ENTITY_REFERENCE_NODE:
case DOMNode::DOCUMENT_FRAGMENT_NODE:
{
if (isReadOnly())
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNodeMemoryManager);
// Remove all childs
DOMNode* current = thisNode->getFirstChild();
while (current != NULL)
{
thisNode->removeChild(current);
current = thisNode->getFirstChild();
}
if (textContent != NULL)
{
// Add textnode containing data
current = ((DOMDocumentImpl*)thisNode->getOwnerDocument())->createTextNode(textContent);
thisNode->appendChild(current);
}
}
break;
case DOMNode::ATTRIBUTE_NODE:
case DOMNode::TEXT_NODE:
case DOMNode::CDATA_SECTION_NODE:
case DOMNode::COMMENT_NODE:
case DOMNode::PROCESSING_INSTRUCTION_NODE:
if (isReadOnly())
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNodeMemoryManager);
thisNode->setNodeValue(textContent);
break;
case DOMNode::DOCUMENT_NODE:
case DOMNode::DOCUMENT_TYPE_NODE:
case DOMNode::NOTATION_NODE:
break;
default:
throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, GetDOMNodeMemoryManager);
}
}
示例2:
void
Importer::addEdgeToScene
(xercesc::DOMNode* edgeNode, Scene* scene)
{
XMLCh* vertex_ch = XMLString::transcode("vertex");
std::vector<int> edge;
for (XMLSize_t i = 0; i < edgeNode->getChildNodes()->getLength(); ++i ) {
DOMNode* node = edgeNode->getChildNodes()->item(i);
// Nodo <vertex>?
if ((node->getNodeType() == DOMNode::ELEMENT_NODE) &&
XMLString::equals(node->getNodeName(), vertex_ch))
edge.push_back(atoi(XMLString::transcode
(node->getFirstChild()->getNodeValue())));
}
// Recuperar los vértices a partir de su index,
// para generar y añadir el arco.
GraphVertex *v1 = scene->getGraph()->getVertex(edge[0]);
GraphVertex *v2 = scene->getGraph()->getVertex(edge[1]);
if (v1 && v2)
{
scene->getGraph()->addEdge(v1, v2);
}
XMLString::release(&vertex_ch);
}
示例3: getValue
string CXmlConfig::getValue(DOMNode* parentNode, const string& itemName)
{
string strValue;
string strName;
DOMNode* firstChildNode = NULL;
charArrayToString(parentNode->getNodeName(), strName);
if (strName == itemName)
{
firstChildNode = parentNode->getFirstChild();
if (firstChildNode != NULL) charArrayToString(firstChildNode->getNodeValue(), strValue);
return strValue;
}
DOMNodeList* nodeList = parentNode->getChildNodes();
for (unsigned int i = 0; i < nodeList->getLength(); ++i)
{
DOMNode* nodeTemp = nodeList->item(i);
if (nodeTemp->getNodeType() == DOMNode::ELEMENT_NODE)
{
charArrayToString(nodeTemp->getNodeName(), strName);
if (strName == itemName)
{
firstChildNode = nodeTemp->getFirstChild();
if (firstChildNode != NULL) charArrayToString(firstChildNode->getNodeValue(), strValue);
break;
}
}
}
return strValue;
}
示例4: ParseXmlFromTMS
// 解析TMS返回xml
bool CTMSSensor::ParseXmlFromTMS(std::string &retXml,int &nRet)
{
XercesDOMParser *ptrParser = new XercesDOMParser;
ptrParser->setValidationScheme( XercesDOMParser::Val_Never );
ptrParser->setDoNamespaces( true );
ptrParser->setDoSchema( false );
ptrParser->setLoadExternalDTD( false );
InputSource* ptrInputsource = new MemBufInputSource((XMLByte*)retXml.c_str(), retXml.size(), "bufId");
try
{
ptrParser->parse(*ptrInputsource);
DOMDocument* ptrDoc = ptrParser->getDocument();
// 读取ret节点
DOMNodeList *ptrNodeList = ptrDoc->getElementsByTagName(C2X("ret"));
if(ptrNodeList == NULL)
{
LOGIDFMT(ULOG_ERROR,ERROR_PARSE_MONITORSTATE_XML,"ParseXmlFromTMS:ret");
return false;
}
else
{
if(ptrNodeList->getLength() == 0)
{
LOGIDFMT(ULOG_ERROR,ERROR_PARSE_MONITORSTATE_XML,"ParseXmlFromTMS:ret");
return false;
}
DOMNode* ptrNode = ptrNodeList->item(0);
char* pstate = XMLString::transcode(ptrNode->getFirstChild()->getNodeValue());
std::string str_state = pstate;
if(!str_state.empty())
{
nRet = atoi(str_state.c_str());
}
XMLString::release(&pstate);
//LOGINFFMT("%s,%s\n",str_name.c_str(),str_state.c_str());
}
}
catch( XMLException& e )
{
char* message = XMLString::transcode( e.getMessage() );
XMLString::release( &message );
LOGIDFMT(ULOG_ERROR,ERROR_PARSE_MONITORSTATE_XML,message);
delete ptrParser;
ptrInputsource = NULL;
delete ptrInputsource;
ptrParser = NULL;
}
delete ptrParser;
delete ptrInputsource;
ptrInputsource = NULL;
ptrParser = NULL;
return true;
}
示例5: fromXml
bool FrameLabelObjectImp::fromXml(DOMNode* pDocument, unsigned int version)
{
if (pDocument == NULL || Service<SessionManager>()->isSessionLoading() == false)
{
return false;
}
if (!TextObjectImp::fromXml(pDocument, version))
{
return false;
}
DOMElement* pElement = static_cast<DOMElement*> (pDocument);
if (pElement != NULL)
{
// Set the autoMode setting (which will also call setLocked)
setAutoMode(StringUtilities::fromXmlString<bool>(A(pElement->getAttribute(X("autoMode")))));
// If the object is not currently locked, load all frames
if (getLocked() == false)
{
for (DOMNode* pChild = pDocument->getFirstChild();
pChild != NULL; pChild = pChild->getNextSibling())
{
if (XMLString::equals(pChild->getNodeName(), X("Animations")))
{
vector<Animation*> animations;
for (DOMNode* pGrandchild = pChild->getFirstChild();
pGrandchild != NULL;
pGrandchild = pGrandchild->getNextSibling())
{
if (XMLString::equals(pGrandchild->getNodeName(), X("Animation")))
{
pElement = dynamic_cast<DOMElement*>(pGrandchild);
if (pElement != NULL)
{
string id(A(pElement->getAttribute(X("id"))));
if (id.empty() != true)
{
Animation* pAnim = dynamic_cast<Animation*>(Service<SessionManager>()->getSessionItem(id));
if (pAnim != NULL)
{
animations.push_back(pAnim);
}
}
}
}
}
setAnimations(animations);
}
}
}
}
return true;
}
示例6: FormatDumpItem
/*!
\brief It fills the member of the _nbPDMLPacket structure that is in charge of the packet dump.
This function extracts the value of the given node, it transforms it into an ascii buffer (appropriately
located into the m_asciiBuffer buffer), and updates the appropriate pointer to it.
This function updates also the pointer into the m_asciiBuffer buffer in order to point to the first
free location in this buffer.
\param PDMLDocument The DOMDocument associated to the current PDML packet.
\param TmpBuffer: pointer to the CAsciiBuffer class, which manages an ascii temporary buffer in which
the content of the XML node has to be stored. The XML content will be stored in binary.
\param ErrBuf: user-allocated buffer (of length 'ErrBufSize') that will keep an error message (if one).
This buffer will always be NULL terminated.
\param ErrBufSize: size of the previous buffer.
\return nbSUCCESS if everything is fine, nbFAILURE if some error occurred.
In case of errors, the error message will be returned in the ErrBuf parameter.
*/
int CPDMLReader::FormatDumpItem(DOMDocument *PDMLDocument, CAsciiBuffer *TmpBuffer, char *ErrBuf, int ErrBufSize)
{
XMLCh TempBuffer[NETPDL_MAX_STRING + 1];
const XMLCh *TempPtr;
char* AsciiBufPtr;
DOMNodeList *DumpList;
DOMNode *DumpItem;
DOMNode *DumpValue;
// Let's initialize this member, just in case
m_packetSummary.PacketDump= NULL;
XMLString::transcode(PDML_DUMP, TempBuffer, NETPDL_MAX_STRING);
// Now, let's get the raw packet dump
DumpList= PDMLDocument->getElementsByTagName(TempBuffer);
if (DumpList == NULL)
return nbSUCCESS;
// Let's check if the PDML fragment contains also the packet dump. If not, let's return.
DumpItem= DumpList->item(0);
if (DumpItem == NULL)
return nbSUCCESS;
DumpValue= DumpItem->getFirstChild();
if (DumpValue == NULL)
return nbSUCCESS;
TempPtr= DumpValue->getNodeValue();
// If the XML element contains that attribute, transform it in ascii and return it to the caller
if (TempPtr && (*TempPtr) )
{
AsciiBufPtr= TmpBuffer->TranscodeAndStore( (wchar_t *)(XMLCh *) TempPtr);
if (AsciiBufPtr == NULL)
{
errorsnprintf(__FILE__, __FUNCTION__, __LINE__, ErrBuf, ErrBufSize, "%s", TmpBuffer->GetLastError() );
return nbFAILURE;
}
// Since we're tranforming an ascii buffer into a bin buffer (which is half the previous one)
// there's no problem of buffer overflow.
ConvertHexDumpAsciiToHexDumpBin(AsciiBufPtr, (unsigned char *) AsciiBufPtr, strlen(AsciiBufPtr) + 1);
m_packetSummary.PacketDump= (unsigned char *) AsciiBufPtr;
}
else // otherwise, append 'NULL'
m_packetSummary.PacketDump= NULL;
return nbSUCCESS;
}
示例7: atof
float
Importer::getValueFromTag
(xercesc::DOMNode* node, const XMLCh *tag)
{
for (XMLSize_t i = 0; i < node->getChildNodes()->getLength(); ++i ) {
DOMNode* aux = node->getChildNodes()->item(i);
if (aux->getNodeType() == DOMNode::ELEMENT_NODE &&
XMLString::equals(aux->getNodeName(), tag))
return atof(XMLString::transcode(aux->getFirstChild()->getNodeValue()));
}
return 0.0;
}
示例8: getSubAlgorithm
bool ConfigurationFileHandler::getSubAlgorithm(std::string algorithm, std::string subalgorithm, std::string* result){
#ifdef BRICS_XERCES_ENABLE
if (errorsOccured) {
return false;
}
DOMNode* current = NULL;
DOMNode* attributeNode = NULL;
XMLCh* algorithmName = XMLString::transcode(algorithm.c_str());
XMLCh* subAlgorithmName = XMLString::transcode(subalgorithm.c_str());
XMLCh* implementationString = XMLString::transcode("implementation");
bool subAlgorithmFound = 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);
//search in children notes
for (current = current->getFirstChild()->getNextSibling(); current!=NULL; current = current->getNextSibling()) {
string nodeName = XMLString::transcode(current->getNodeName());
if (nodeName.compare(subalgorithm) == 0) {
DOMNamedNodeMap* attributesList = current->getAttributes();
attributeNode = attributesList->getNamedItem(implementationString);
if (attributeNode != 0) {
*result = XMLString::transcode(attributeNode->getNodeValue());
subAlgorithmFound = true;
break; //take only first found
}
}
}
XMLString::release(&algorithmName);
XMLString::release(&subAlgorithmName);
XMLString::release(&implementationString);
return subAlgorithmFound;
#else
return false;
#endif
}
示例9: verifyDescriptorElement
void AcsAlarmTestCase::verifyDescriptorElement(DOMDocument * doc)
{
// Verify the descriptor element
DOMNodeList * descriptorNodes = doc->getElementsByTagName(DESCRIPTOR_TAG_NAME);
CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no descriptor element found",
(NULL != descriptorNodes && descriptorNodes->getLength() == 1));
// check value of descriptor
DOMNode * descriptorElementNode = descriptorNodes->item(0);
DOMNode * descriptorTextNode = descriptorElementNode->getFirstChild();
CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; descriptor value is not present or null",
(NULL != descriptorTextNode));
const XMLCh * descriptorNodeValue = descriptorTextNode->getNodeValue();
CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of descriptor is not correct",
(NULL != descriptorNodeValue && XMLString::equals(descriptorNodeValue, DESCRIPTOR_VALUE_XMLCH)));
}
示例10: ReadRootNode
void ColladaObject::ReadRootNode(const DOMNode* node)
{
_ASSERTE(node != NULL);
DOMNode* currentNode = node->getFirstChild();
while( currentNode != NULL )
{
#if _DEBUG // デバッグ時に名前をチェックする為に
const XMLCh* name = currentNode->getNodeName();
#endif
if( IsElementNode( currentNode ) )
{
if( Is_COLLADA_NodeName( currentNode ) ) // COLLADA要素が見つかった場合
{
currentNode = currentNode->getFirstChild(); // 子ノードを処理する
continue;
}
else if( Is_asset_NodeName( currentNode ) ) // asset要素が見つかった場合
{
_ASSERTE(elemAsset == NULL); // 必ず1つ存在するのでこの時点ではNULL
elemAsset = new AssetElement();
elemAsset->ReadNode( currentNode );
}
else if( Is_library_NodeName( currentNode ) ) // library要素が見つかった場合
{
LibraryElement* elemLibrary = CreateLibraryElement( currentNode );
if( elemLibrary != NULL )
{
elemLibrary->ReadNode( currentNode );
vecElemLibrary.push_back( elemLibrary );
}
}
else if( Is_scene_NodeName( currentNode ) ) // scene要素が見つかった場合
{
_ASSERTE(elemScene == NULL); // 0または1つ存在するのでこの時点ではNULL
elemScene = new SceneElement();
elemScene->ReadNode( currentNode );
}
}
currentNode = currentNode->getNextSibling(); // 次の要素を処理する
}
}
示例11: GetString
void DomSerializer::GetString(const char* key, CStdString& value, bool required)
{
// Find the right node
DOMNode* stringNode = FindElementByName(m_node, CStdString(key));
if(stringNode)
{
// Now, the string associated to element should be the first child (text element)
DOMNode* textNode = stringNode->getFirstChild();
if (textNode && textNode->getNodeType() == DOMNode::TEXT_NODE)
{
value = XMLStringToLocal(textNode->getNodeValue());
}
}
else if (required)
{
throw(CStdString("DomSerializer::GetString: required parameter missing:") + key);
}
}
示例12: fromXml
bool ArcObjectImp::fromXml(DOMNode* pDocument, unsigned int version)
{
if (pDocument == NULL)
{
return false;
}
bool bSuccess = false;
// Load the ellipse properties first to ensure that it has a valid bounding box when loading the arc properties
DOMNode* pObjectNode = NULL;
for (pObjectNode = pDocument->getFirstChild(); pObjectNode != NULL; pObjectNode = pObjectNode->getNextSibling())
{
if (XMLString::equals(pObjectNode->getNodeName(), X("objects")))
{
DOMNode* pEllipseNode = NULL;
for (pEllipseNode = pObjectNode->getFirstChild();
pEllipseNode != NULL;
pEllipseNode = pEllipseNode->getNextSibling())
{
if (XMLString::equals(pEllipseNode->getNodeName(), X("Graphic")))
{
DOMElement* pElement(static_cast<DOMElement*> (pEllipseNode));
string type(A(pElement->getAttribute(X("type"))));
GraphicObjectType objectType = StringUtilities::fromXmlString<GraphicObjectType>(type);
if (objectType == ELLIPSE_OBJECT)
{
bSuccess = mpEllipse->fromXml(pEllipseNode, version);
break;
}
}
}
}
}
if (bSuccess == true)
{
bSuccess = FilledObjectImp::fromXml(pDocument, version);
}
return bSuccess;
}
示例13: fromXml
bool ScaleBarObjectImp::fromXml(DOMNode* pDocument, unsigned int version)
{
if (pDocument == NULL)
{
return false;
}
bool bSuccess = FilledObjectImp::fromXml(pDocument, version);
if (bSuccess == true)
{
mpGroup->removeAllObjects(true);
DOMNode* pObjectNode = pDocument->getFirstChild();
while (pObjectNode != NULL)
{
if (XMLString::equals(pObjectNode->getNodeName(), X("objects")))
{
DOMNode* pGroupNode = pObjectNode->getFirstChild();
while (pGroupNode != NULL)
{
if (XMLString::equals(pGroupNode->getNodeName(), X("Graphic")))
{
DOMElement* pElement(static_cast<DOMElement*> (pGroupNode));
string type(A(pElement->getAttribute(X("type"))));
GraphicObjectType objectType = StringUtilities::fromXmlString<GraphicObjectType>(type);
if (objectType == GROUP_OBJECT)
{
bSuccess = mpGroup->fromXml(pGroupNode, version);
break;
}
}
pGroupNode = pGroupNode->getNextSibling();
}
}
pObjectNode = pObjectNode->getNextSibling();
}
}
return bSuccess;
}
示例14: applyInsertAsFirst
void XercesUpdateFactory::applyInsertAsFirst(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMNode *domnode = const_cast<DOMNode*>(nodeImpl->getDOMNode());
DOMNode *firstChild = domnode->getFirstChild();
DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(domnode));
bool untyped = nodeImpl->dmNodeKind() == Node::element_string &&
XPath2Utils::equals(nodeImpl->getTypeName(), DocumentCache::g_szUntyped) &&
XPath2Utils::equals(nodeImpl->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
bool containsElementOrText = false;
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);
if(childImpl->dmNodeKind() == Node::element_string ||
childImpl->dmNodeKind() == Node::text_string) {
containsElementOrText = true;
}
// If the type-name property of $target is xs:untyped, then upd:setToUntyped() is invoked on each
// element or attribute node in $content.
if(!untyped) setTypes(newChild, childImpl->getDOMNode());
// For each node in $content, the parent property is set to parent($target).
// The children property of $target is modified to add the nodes in $content just before $target,
// preserving their order.
domnode->insertBefore(newChild, firstChild);
}
// If at least one of the nodes in $content is an element or text node, upd:removeType($target) is invoked.
if(containsElementOrText) {
removeType(domnode);
}
addToPutSet(update.getTarget(), &update, context);
}
示例15: clsSettingsReaderException
list<string> ClsSettingsReader::getListLastFiles() {
#ifdef DEBUG_CLSSETTINGSREADER
cout << "ClsSettingsReader::getListLastFiles()" << endl;
#endif
list<string> lstLFO;
if(iSysSettingReaderState != PARSER_BUFFER_PARSED){
ClsSettingsReaderException clsSettingsReaderException(ClsSettingsReaderException::BUFFER_NOT_PARSED);
throw clsSettingsReaderException;
}
DOMNodeList* dnlstTemp = ddocIqrSetting->getElementsByTagName(XMLString::transcode(ClsTagLibrary::lastFilesOpen()));
DOMNode* dnTemp=NULL;
if ( dnlstTemp->getLength() == 1){
dnTemp = dnlstTemp->item(0);
} else if ( dnlstTemp->getLength() < 1) {
ClsSettingsReaderException clsSettingsReaderException(ClsSettingsReaderException::ENTITY_NOT_FOUND);
throw clsSettingsReaderException;
}
DOMNodeList* dnlstFiles = dnTemp->getChildNodes();
unsigned int ii = 0;
while( ii< dnlstFiles->getLength()){
DOMNode* dnTempTemp = dnlstFiles->item(ii);
if(dnTempTemp->getNodeType() == 1){
DOMNode* dnValue = dnTempTemp->getFirstChild();
if(dnValue!=NULL){
string strValue = XMLString::transcode(dnValue->getNodeValue());
lstLFO.push_back(strValue);
}
}
ii++;
}
return lstLFO;
};