本文整理汇总了C++中CXMLNode::AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C++ CXMLNode::AppendChild方法的具体用法?C++ CXMLNode::AppendChild怎么用?C++ CXMLNode::AppendChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CXMLNode
的用法示例。
在下文中一共展示了CXMLNode::AppendChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateTargets
//.........这里部分代码省略.........
// get target node
ret = nodeTargetRoot.GetNodeFromIdPath(strIdPathTarg, nodeTarget);
ASSERT(ret);
if (!ret)
{
continue;
}
// get attributes of the target node
nodeTarget.GetAttribute(CE_XMLATTR_TEXT, strTText);
nodeTarget.GetAttribute(CE_XMLATTR_ID, strTId);
nodeTarget.GetAttribute(CE_XMLATTR_TYPE, strTType);
nodeTarget.GetAttribute(CE_XMLATTR_ADDR, strTAddress);
nodeTarget.GetAttribute(CE_XMLATTR_USERADDR, strTUserAddress);
nodeTarget.GetAttribute(CE_XMLATTR_CONSOLE_ADDR, strTConsoleAddress);
nodeTarget.GetAttribute(CE_XMLATTR_RESOURCE, strTAssignedResource);
nodeTarget.GetAttribute(CE_XMLATTR_SOURCE, strTSource);
nodeTarget.GetAttribute(CE_XMLATTR_WAIT_TARGET_CONN , strWaitForTarget);
strInstType = strTType + CE_XML_INST_ADD;
strParseSource = strTId + _T(".") + CE_INSTANCE_EXT;
strParseSourceNew = CString(CE_GEN_PATH) + _T("\\") + strTId + _T("\\") + strParseSource;
// does node already exist in instance tree:
TInstanceTargetInfo* pInstTargetInfo = NULL;
CString strLowerId = strTargetId;
strLowerId.MakeLower();
if (m_mapInstanceTargets.Lookup(strLowerId, pInstTargetInfo))
{
// *** existing node ***
ASSERT(pInstTargetInfo);
pInstTargetInfo->bUsed = TRUE;
nodeInstance = pInstTargetInfo->xmlNode;
ret = nodeInstanceRoot.AppendChild(nodeInstance, TRUE);
ASSERT(ret);
// check if attributes have changed
// get instance node attributes
CString strInstText;
CString strInstId;
//CString strInstType;
CString strInstAddress;
CString strInstUserAddress;
CString strInstConsoleAddress;
CString strInstAssignedResource;
CString strInstSource;
nodeInstance.GetAttribute(CE_XMLATTR_TEXT, strInstText);
nodeInstance.GetAttribute(CE_XMLATTR_ID, strInstId);
//nodeInstance.GetAttribute(CE_XMLATTR_TYPE, strInstType); // type can't change
nodeInstance.GetAttribute(CE_XMLATTR_ADDR, strInstAddress);
nodeInstance.GetAttribute(CE_XMLATTR_USERADDR, strInstUserAddress);
nodeInstance.GetAttribute(CE_XMLATTR_CONSOLE_ADDR, strInstConsoleAddress);
nodeInstance.GetAttribute(CE_XMLATTR_RESOURCE, strInstAssignedResource);
nodeInstance.GetAttribute(CE_XMLATTR_SOURCE, strInstSource);
if ((strInstText.CompareNoCase(strTText)!=0)
|| (strInstId.CompareNoCase(strTId)!=0)
//|| (strInstType.CompareNoCase(strType)!=0)
|| (strInstAddress.CompareNoCase(strTAddress)!=0)
|| (strInstConsoleAddress.CompareNoCase(strTConsoleAddress)!=0)
|| (strInstAssignedResource.CompareNoCase(strTAssignedResource)!=0)
|| (strInstSource.CompareNoCase(strTSource) != 0))
{
// node has changed -> update nodes
nodeInstance.SetAttribute(CE_XMLATTR_TEXT, strTText);
示例2: InitTree
/**
* InitTree
* initialize the instance tree for the first time: get all necessary
* information from the kad and construct root and classes group nodes
*
* @return TRUE: on success
* FALSE: else
* @exception -
* @see
*/
BOOL CInstanceTree::InitTree()
{
GetStaticInfos();
// create project node
CXMLNode docRoot;
CXMLNode projectNode;
PROJ_MAN_ASSERT(m_pProjectManager);
CString strProjNodeId;
strProjNodeId = m_pProjectManager->GetProjectName()+_T(".")+ID_PATH_INSTANCEVIEW;
CString strVersion;
strVersion.Format(_T("%i"), PRODUCT_BUILD);
if ( (!m_domDocument.GetDocNode(docRoot))
||(!m_domDocument.CreateNode(projectNode, CE_XMLTAG_NODE))
||(!docRoot.AppendChild(projectNode))
||(!projectNode.SetAttribute(CE_XMLATTR_TEXT, m_pProjectManager->GetProjectName()))
||(!projectNode.SetAttribute(CE_XMLATTR_ID, strProjNodeId))
||(!projectNode.SetAttribute(CE_XMLATTR_PARSERSOURCE, m_pProjectManager->GetProjectFileName()))
||(!projectNode.SetAttribute(CE_XMLATTR_TYPE, m_strInstancesType))
||(!projectNode.SetAttribute(PRJMAN_VERSION, strVersion)) )
{
return FALSE;
}
Reparse4CPAttributes(&projectNode);
// add project file to source file list
TSourceFileInfo* pProjFileInfo;
CString strProjFileName = m_pProjectManager->GetProjectFileName();
pProjFileInfo = CreateSourceFileInfo(strProjFileName,
projectNode, _T(""));
PROJ_MAN_ASSERT(pProjFileInfo);
pProjFileInfo->strIdPath = CE_XML_IDPATH_SEP + strProjNodeId;
SetSourceTime(pProjFileInfo, m_pProjectManager->GetProjectFileNameWithPath());
SourceFileMap_SetAt(strProjFileName, pProjFileInfo, m_mapSourceFiles);
// update targets
UpdateTargets();
Reparse(FALSE);
ExpandFromViewData();
IXMLDOMDocument *pXMLDoc;
m_domDocument.GetIXMLDocument(&pXMLDoc);
m_pProjectManager->Fire_InitInstanceTree((IUnknown*)pXMLDoc);
pXMLDoc->Release();
m_bInit = FALSE;
POSITION pos = m_mapInstanceTargets.GetStartPosition();
while(pos)
{
CString strId;
TInstanceTargetInfo* pInfo;
m_mapInstanceTargets.GetNextAssoc(pos, strId, pInfo);
if (pInfo)
{
CComBSTR sId = pInfo->strTargetId;
CComBSTR sIdPath = pInfo->strIdPath;
m_pProjectManager->Fire_TargetInstanceAdded(sId, sIdPath);
}
}
return TRUE;
}
示例3: SaveToNode
// 15.12.05 SIS >>
// added parameter crstrIndex
// to save index range
bool CCeWatchElement::SaveToNode(CXMLNode& rtNode, CXMLDocument& rtDocument, const CString& crstrIndexRange)
// 15.12.05 SIS <<
{
bool bReturn = true;
// don't forget to increment the version string if you change anything here
CString str;
if(m_bInitExpanded)
{
rtNode.SetAttribute(CEWATCH_XMLATTR_EXPANDED, _T("1"));
}
CString strExpression = m_Name;
if(!crstrIndexRange.IsEmpty())
{
strExpression.Format(_T("%s, %s"), m_Name, crstrIndexRange);
}
rtNode.SetAttribute(CEWATCH_XMLATTR_EXPRESSION, strExpression);
if (m_Type.GetName().GetLength() > 0)
{
str.Format("%s;%d", m_Type.GetName(), (int)m_Type.GetVarKind());
rtNode.SetAttribute(CEWATCH_XMLATTR_TYPE, str);
}
rtNode.SetAttribute(CEWATCH_XMLATTR_VALUE, m_strValue);
if (m_strFormat.GetLength() > 0)
{
rtNode.SetAttribute(CEWATCH_XMLATTR_FORMAT, m_strFormat);
}
// #2149 10.10.06 SIS >>
// only save visible array elements
int iNumChildren = GetChildrenCount();
int iChildStart = 0;
int iChildStop = iNumChildren-1;
if(m_Type.IsArray())
{
VERIFY(ExtractArrayIndices(crstrIndexRange, iChildStart, iChildStop));
iChildStart = max(iChildStart - m_Type.GetArrayLowerBound(), 0);
iChildStop = min(iChildStop - m_Type.GetArrayLowerBound(), iNumChildren-1);
}
CCeWatchElement* pElem = NULL;
for (int iChild = iChildStart; iChild <= iChildStop; iChild++)
// #2149 10.10.06 SIS <<
{
CXMLNode tNodeChild;
if(rtDocument.CreateNode(tNodeChild, CEWATCH_XMLTAG_VARNODE))
{
pElem = GetChild(iChild);
if(!pElem)
{
break;
}
bReturn &= pElem->SaveToNode(tNodeChild, rtDocument, _T(""));
if(!bReturn)
{
break;
}
rtNode.AppendChild(tNodeChild);
}
}
return bReturn;
}