本文整理汇总了C++中msxml2::IXMLDOMNamedNodeMapPtr::Getitem方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNamedNodeMapPtr::Getitem方法的具体用法?C++ IXMLDOMNamedNodeMapPtr::Getitem怎么用?C++ IXMLDOMNamedNodeMapPtr::Getitem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMNamedNodeMapPtr
的用法示例。
在下文中一共展示了IXMLDOMNamedNodeMapPtr::Getitem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAttrsOfNode
int CXmlBase::GetAttrsOfNode(map<CString, CComBSTR>& mapAttrs, MSXML2::IXMLDOMNodePtr pNode)
{
MSXML2::IXMLDOMNamedNodeMapPtr pAttrs;
MSXML2::IXMLDOMNodePtr pAttr;
HRESULT hr;
CComBSTR bstrText;
CString str;
long lAttrCount = 0;
mapAttrs.clear();
if (NULL == pNode)
{
//WRITELOG("END, pNode为空");
return 0;
}
pAttrs = pNode->Getattributes();
if (pAttrs == NULL)
{
//WRITELOG("END, 取得节点属性集合失败");
return 0;
}
lAttrCount = pAttrs->Getlength();
for (int i=0; i<lAttrCount; i++)
{
pAttr = pAttrs->Getitem(i);
if (pAttr == NULL)
{
//WRITELOG("取得第[%d]个属性为空", i);
continue;
}
hr = pAttr->get_nodeName(&bstrText);
if (FAILED(hr))
{
//WRITELOG("取得第[%d]个属性名为空", i);
continue;
}
if (!ConvertBSTR2CString(str, bstrText.m_str))
{
//WRITELOG("转换第[%d]个属性名 失败", i);
continue;
}
hr = pAttr->get_text(&bstrText);
if (FAILED(hr))
{
//WRITELOG("取得第[%d]个属性值 失败,属性[%s]", i, str);
continue;
}
mapAttrs.insert(make_pair(str, bstrText));
}
return (int)mapAttrs.size();
}
示例2: getFirstAttribute
XMLAttribute XMLElement::getFirstAttribute() const {
XMLAttribute attr;
MSXML2::IXMLDOMNamedNodeMapPtr attrs;
if (nodePtr) {
if ((nodePtr->get_attributes(&attrs)) == S_OK) {
if (attrs->Getlength() > 0) {
attr.attrPtr = attrs->Getitem(0);
}
}
}
return attr;
}
示例3: GetAttribName
CString CXmlNodeWrapper::GetAttribName(int index)
{
if (IsValid())
{
MSXML2::IXMLDOMNamedNodeMapPtr attribs = m_xmlnode->Getattributes();
if (attribs)
{
MSXML2::IXMLDOMAttributePtr attrib = attribs->Getitem(index);
if (attrib)
return (LPCTSTR)attrib->Getname();
}
}
return _T("");
}
示例4: _parseNodeGetAttributes
void XmlParser::_parseNodeGetAttributes(MSXML2::IXMLDOMNode *pIDOMNode, XmlNode& node)
{
MSXML2::IXMLDOMNamedNodeMapPtr attributes = pIDOMNode->attributes;
BSTR attrName;
for (int i = 0; i < attributes->Getlength(); i++)
{
MSXML2::IXMLDOMNodePtr atrr = attributes->Getitem(i);
atrr->get_nodeName(&attrName);
_variant_t val = atrr->GetnodeValue();
wstring name(attrName);
BSTR b = val.bstrVal;
wstring value(b);
XmlAttribute attribute(name, value);
node.AddAttribute(attribute);
}
}