本文整理汇总了C++中IXMLDOMNode::put_nodeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::put_nodeValue方法的具体用法?C++ IXMLDOMNode::put_nodeValue怎么用?C++ IXMLDOMNode::put_nodeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::put_nodeValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateCommentNode
/*
Function name : CXML::CreateCommentNode
Description : This helper function creates a comment for the node supplied as argumnet
Return type : bool
Argument : IXMLDOMNode **pParentNode
Argument : CString csComment
*/
bool CXML::CreateCommentNode(IXMLDOMNode **ppParentNode,CString &rcsComment)
{
if(rcsComment.IsEmpty())
return false;
if(!(*ppParentNode))
return false;
IXMLDOMNode * pNode = NULL;
_variant_t vtNodeType((long)VT_I4,NODE_COMMENT);
_bstr_t bstrNameSpace("");
m_hr = m_pXMLDoc->createNode(vtNodeType,bstrNameSpace,bstrNameSpace,&pNode);
if(!SUCCEEDED(m_hr))
return false;
_variant_t vtComment(rcsComment);
m_hr = pNode->put_nodeValue(vtComment);
if(!SUCCEEDED(m_hr))
{
pNode->Release();
return false;
}
IXMLDOMNode * pINewNode = NULL;
bool bRet = AddNode(&m_pICurrentNode,&pNode,&pINewNode,NODE_COMMENT);
if(pNode)
pNode->Release();
if(pINewNode)
pINewNode->Release();
return bRet;
}
示例2: CreateAttributeNode
/*
Function name : CXML::CreateAttributeNode
Description :
Return type : bool
Argument : IXMLDOMNode **pParentNode
Argument : CString csAttribute
Argument : CString csValue
Tested : Ok
*/
bool CXML::CreateAttributeNode(IXMLDOMNode **pParentNode,CString csAttribute,CString csValue)
{
IXMLDOMNode * pNode = NULL;
if(csAttribute.IsEmpty())
return false;
if(!(*pParentNode))
return false;
_variant_t vtNodeType((long)NODE_ATTRIBUTE);
_bstr_t bstrName(csAttribute);
_bstr_t bstrNameSpace("");
m_hr = m_pXMLDoc->createNode(vtNodeType,bstrName,bstrNameSpace,&pNode);
if(!SUCCEEDED(m_hr))
return false;
IXMLDOMNamedNodeMap * pAttributes = NULL;
m_hr = (*pParentNode)->get_attributes(&pAttributes);
if(!SUCCEEDED(m_hr) || !pAttributes)
{
pNode->Release();
return false;
}
IXMLDOMNode *pNewNode = NULL;
m_hr = pAttributes->setNamedItem(pNode,&pNewNode);
pNode->Release();
pAttributes->Release();
if(!SUCCEEDED(m_hr) || !pNewNode)
return false;
_variant_t vtValue(csValue);
m_hr = pNewNode->put_nodeValue(vtValue);
pNewNode->Release();
if(!SUCCEEDED(m_hr) || !pNewNode)
return false;
return true;
}
示例3: SetValueByPattern
HRESULT CKADmerge::SetValueByPattern(string sElementPattern,
string sAttributePattern,
string sValue,
string sLogFile)
{
HRESULT hRes = 0;
if(sLogFile != "")
{
// open log file
OpenLog(sLogFile, sDescription + " " + m_sFileName);
}
IXMLDOMNode * pElemNode = NULL;
IXMLDOMNode * pAttrNode = NULL;
_bstr_t bElementPattern(sElementPattern.c_str());
try
{
// get element node
hRes = m_pXMLKad->selectSingleNode(bElementPattern, &pElemNode);
if(hRes == S_FALSE)
{
hRes = S_FALSE;
throw string("node access error");
}
if(sAttributePattern.length())
{
// get attribute node by pattern string
_bstr_t bAttributePattern(sAttributePattern.c_str());
hRes = pElemNode->selectSingleNode(bAttributePattern, &pAttrNode);
if(hRes == S_FALSE)
{
throw string("node access error");
}
// set attribute value
_bstr_t bAttlanguage(sValue.c_str());
VARIANT vAttlanguage;
vAttlanguage.vt = VT_BSTR;
V_BSTR(&vAttlanguage) = bAttlanguage.copy();
hRes = pAttrNode->put_nodeValue(vAttlanguage);
VariantClear(&vAttlanguage);
}
else
{
// set element value
hRes = SetValue(pElemNode, sValue);
}
if(hRes == S_OK)
{
SaveXMLFile(m_sFileName, m_pXMLKad);
// log changes
Log("SetValueByPattern - Set value succeeded: Element '" + sElementPattern + " - Attribute " + sAttributePattern + "' to: " + sValue);
}
//delete pwAttlanguage;
if(FAILED(hRes))
{
hRes = S_FALSE;
throw string("value error");
}
}
catch(string str)
{
hRes = S_FALSE;
// log changes
Log("SetValueByPattern - Set value failed: Element '" + sElementPattern + " - Attribute " + sAttributePattern + "' to: " + sValue);
Log("ERROR: " + str);
}
if(pElemNode != NULL)
pElemNode->Release();
if(pAttrNode != NULL)
pAttrNode->Release();
// close log file
CloseLog();
return hRes;
}