本文整理汇总了C++中CXmlNode类的典型用法代码示例。如果您正苦于以下问题:C++ CXmlNode类的具体用法?C++ CXmlNode怎么用?C++ CXmlNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CXmlNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadValueString
std::wstring CXmlNode::ReadValueString(const std::wstring& sName, const std::wstring& nDef)
{
CXmlNode oTemp;
if (GetNode(sName, oTemp))
return oTemp.GetText();
return L"";
}
示例2: xpath
HRESULT CXmlDocument::SetXmlDocument(VARIANT* pXmlDocument, bool& bLoginPage,bool bCheckLogin, bool& bErrXml)
{
bCheckLogin;
bErrXml = false;
bLoginPage = false;
CString xpath(_T("//AwsTimeout/Url"));
CString errpath(_T("//Error"));
CXmlNode node;
if (SetXmlDocument(pXmlDocument)==S_OK)
{
if (m_pNode!=NULL)
{
node = Find(xpath);
if (!node.IsNull())
bLoginPage = true;
node = Find(errpath);
if(!node.IsNull())
bErrXml = true;
}
}
return S_OK;
}
示例3: CDefaultRecord
//----------------------------------------
CDefaultRecord* CAliasesDictionary::CreateDefaultRecord(CXmlNode* defaultRecordNode)
{
if (defaultRecordNode == NULL)
{
return NULL;
}
CDefaultRecord* defaultRecord = new CDefaultRecord();
std::string value;
bool bOk = defaultRecordNode->GetPropVal(CAliasesDictionary::m_NAME_ATTR, &value);
if (!bOk)
{
std::string msg = CTools::Format("Unable to create default record - Default record name is empty - "
"Please check all '%s' attributes of the '%s' elements in the aliases dictionary '%s'.",
CAliasesDictionary::m_NAME_ATTR.c_str(),
CAliasesDictionary::m_DEFAULT_RECORD_ELT.c_str(),
m_fullFileName.c_str());
delete defaultRecord;
defaultRecord = NULL;
throw CXMLException(msg, BRATHL_ERROR);
}
defaultRecord->SetName(value);
CObArray arrayNodes(false);
FindAllNodesByName(CAliasesDictionary::m_PRODUCT_TYPE_ELT, defaultRecordNode, arrayNodes, false);
CObArray::const_iterator it;
for(it = arrayNodes.begin() ; it != arrayNodes.end() ; it++)
{
CXmlNode* node = dynamic_cast<CXmlNode*>(*it);
if (node == NULL)
{
continue;
}
CXmlNode* textNode = node->GetChildren();
if (textNode == NULL)
{
continue;
}
std::string productType = textNode->GetContent().c_str();
if (productType.empty())
{
continue;
}
defaultRecord->AddProductType(productType);
}
return defaultRecord;
}
示例4: SetNodeAttribute
bool CXmlDocument::SetNodeAttribute(const CXmlNode& node, const CString& attributeName, const CString& value)
{
if(node.GetNode() == NULL)
return FALSE;
XmlAttribute pAttr;
HRESULT hr = m_pDoc->createAttribute((_bstr_t)attributeName, &pAttr);
if ( FAILED(hr) )
return FALSE;
hr = pAttr->put_text((_bstr_t)value);
if( FAILED(hr) )
return FALSE;
XmlMap pNodeMap;
hr = node.GetNode()->get_attributes(&pNodeMap);
if ( FAILED(hr) )
return FALSE;
XmlNode pNamedItem;
hr = pNodeMap->setNamedItem(pAttr, &pNamedItem);
if ( FAILED(hr) )
return FALSE;
return TRUE;
}
示例5: GetFirstChildNode
BOOL CXmlNode::GetFirstChildNode(LPCTSTR pNodeName, CXmlNode& objXmlNode)
{
IXMLDOMNode * pXMLNode, * pTmpXMLNode;
BSTR bstrNodeName;
HRESULT hr;
if (!pNodeName || !m_pXMLNode)
return FALSE;
pXMLNode = NULL;
hr = m_pXMLNode->get_firstChild(&pXMLNode);
while (hr == S_OK)
{
bstrNodeName = NULL;
hr = pXMLNode->get_nodeName(&bstrNodeName);
if (hr == S_OK)
{
int nRet = wcscmp(bstrNodeName, pNodeName);
::SysFreeString(bstrNodeName);
if (nRet == 0)
{
objXmlNode.Attach(pXMLNode);
return TRUE;
}
}
pTmpXMLNode = NULL;
hr = pXMLNode->get_nextSibling(&pTmpXMLNode);
pXMLNode->Release();
pXMLNode = pTmpXMLNode;
}
objXmlNode.Attach(NULL);
return FALSE;
}
示例6: SelectSingleNode
BOOL CXmlDocument::SelectSingleNode(LPCTSTR pNodeName, CXmlNode& objXmlNode)
{
IXMLDOMNode * pXMLNode;
BSTR bstrNodeName;
HRESULT hr;
if (NULL == pNodeName || NULL == m_pXMLDoc)
return FALSE;
bstrNodeName = ::SysAllocString(pNodeName);
pXMLNode = NULL;
hr = m_pXMLDoc->selectSingleNode(bstrNodeName, &pXMLNode);
::SysFreeString(bstrNodeName);
if (hr == S_OK)
{
objXmlNode.Attach(pXMLNode);
return TRUE;
}
else
{
objXmlNode.Attach(NULL);
return FALSE;
}
}
示例7: LoadNonFillVecElem
BOOL CXMLVecLS::LoadNonFillVecElem(COutlined *pElem,CXmlNode &node)
{
pElem->SetDasHStyle(node.GetIntAttrib(_T("DashStyle")));
pElem->SetOutlineWidth(node.GetIntAttrib(_T("OutlineWidth")));
pElem->SetOutlineColor(node.GetUIntAttrib(_T("OutlineColor")));
return TRUE;
}
示例8: GetNameSpaces
CString CXmlDocument::GetNameSpaces()
{
CString cstr,xpath,name,ns;
int at;
long count;
count = m_pDoc->namespaces->length;
CXmlNode node;
for(long i =0;i<count;++i)
{
ns = (LPCTSTR)m_pDoc->namespaces->namespaceURI[i];
xpath.Format(_T("//*[namespace-uri()='%s']"),ns);
node = this->Find(xpath);
if(node.IsValid())
{
name = node.GetName();
if((at=name.Find(_T(":"),0))>=0)
{
if(!cstr.IsEmpty()) cstr += _T(" ");
cstr.AppendFormat(_T("xmlns:%s='%s'"),name.Left(at),ns);
}
}
}
return cstr;
}
示例9: ReadValueString
CString CXmlNode::ReadValueString(const CString& sName, const CString& nDef)
{
CString sRes;
CXmlNode oTemp;
if(GetNode(sName, oTemp))
sRes = oTemp.GetText();
return sRes;
}
示例10: SetNodeValue
void CXmlNode::SetNodeValue(const CString& xpath, const CString& value)
{
CXmlNode node = this->Find(xpath);
if(node.IsNull())
return;
else
node.SetValue(value);
}
示例11: SaveFilledVecElem
void CXMLVecLS::SaveFilledVecElem(const CFilled *pElem,CXmlNode &node)
{
node.SetAttrib(_T("Outline"),pElem->IsOutline());
node.SetAttrib(_T("DashStyle"),pElem->GetDashStyle());
node.SetAttrib(_T("OutlineWidth"),pElem->GetOutlineWidth());
node.SetAttrib(_T("OutlineColor"),pElem->GetOutlineColor());
node.SetAttrib(_T("Fill"),pElem->IsFill());
node.SetAttrib(_T("FillColor"),pElem->GetFillColor());
}
示例12: LoadMiscConfig
// 加载杂项配置
BOOL LoadMiscConfig(LPCTSTR lpszFileName)
{
CXmlDocument xmlDoc;
CXmlNode xmlNode;
BOOL bRet = xmlDoc.Load(lpszFileName);
if (!bRet)
return FALSE;
bRet = xmlDoc.SelectSingleNode(_T("/Misc/FontInfo"), xmlNode);
if (bRet)
{
g_fontInfo.m_strName = xmlNode.GetAttribute(_T("Name"));
g_fontInfo.m_nSize = xmlNode.GetAttributeInt(_T("Size"));
tstring strColor = xmlNode.GetAttribute(_T("Color"));
g_fontInfo.m_clrText = HexStrToRGB(strColor.c_str());
g_fontInfo.m_bBold = xmlNode.GetAttributeInt(_T("Bold"));
g_fontInfo.m_bItalic = xmlNode.GetAttributeInt(_T("Italic"));
g_fontInfo.m_bUnderLine = xmlNode.GetAttributeInt(_T("UnderLine"));
}
bRet = xmlDoc.SelectSingleNode(_T("/Misc/HotKey"), xmlNode);
if (bRet)
{
tstring strHotKey = xmlNode.GetText();
g_cHotKey = toupper(strHotKey.at(0));
}
xmlNode.Release();
xmlDoc.Release();
return TRUE;
}
示例13: Do
void CComplexTest::Do(const _tstring & sFileName)
{
CXmlNode xmlData;
boost::property_tree::xml_parser::read_xml(sFileName, xmlData);
const CXmlNode& xmlCase = xmlData.get_child(_T("complex_test.cases.case"));
CTestCase Case;
Case.Execute(xmlCase);
}
示例14:
_variant_t CXmlNode::GetNodeAttributeData(LPCTSTR xpath,LPCTSTR attrname,const _variant_t defVar)
{
CXmlNode node = this->Find(xpath);
if(node.IsNull())
{
return defVar;
}
else
{
return node.GetAttributeData(attrname, defVar); //Using the default value specified by a client
}
}
示例15: GetNodeAttribute
CString CXmlNode::GetNodeAttribute(LPCTSTR xpath,LPCTSTR attrname)
{
CXmlNode node = this->Find(xpath);
if(node.IsNull())
{
return _T("");
}
else
{
return node.GetAttribute(attrname);
}
}