コード例 #1
0
bool XmlIOStreamImp::ReadNodeAttribute(const CString& attrName, CString& attrValue)
{
	DATA_ASSERT(mpCurrentNode != NULL);
	if(NULL == mpCurrentNode)
		return false;

	MSXML2::IXMLDOMNamedNodeMapPtr attribs = mpCurrentNode->Getattributes();
	
	MSXML2::IXMLDOMNodePtr pAttr = attribs->getNamedItem((LPCTSTR)attrName);
	if(NULL == pAttr)
		return false;

	attrValue = pAttr->GetnodeValue();
	return true;
}
コード例 #2
0
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);
	}
}