OLD | NEW |
(Empty) | |
| 1 #include "MsHTMLUtils.h" |
| 2 |
| 3 GetHtmlElementAttributeResult GetHtmlElementAttribute(IHTMLElement& htmlElement, |
| 4 const ATL::CComBSTR& attributeName) |
| 5 { |
| 6 GetHtmlElementAttributeResult retValue; |
| 7 ATL::CComVariant vAttr; |
| 8 ATL::CComPtr<IHTMLElement4> htmlElement4; |
| 9 if (FAILED(htmlElement.QueryInterface(&htmlElement4)) || !htmlElement4) |
| 10 { |
| 11 return retValue; |
| 12 } |
| 13 ATL::CComPtr<IHTMLDOMAttribute> attributeNode; |
| 14 if (FAILED(htmlElement4->getAttributeNode(attributeName, &attributeNode)) || !
attributeNode) |
| 15 { |
| 16 return retValue; |
| 17 } |
| 18 // we set that attribute found but it's not necessary that we can retrieve its
value |
| 19 retValue.isAttributeFound = true; |
| 20 if (FAILED(attributeNode->get_nodeValue(&vAttr))) |
| 21 { |
| 22 return retValue; |
| 23 } |
| 24 if (vAttr.vt == VT_BSTR && vAttr.bstrVal) |
| 25 { |
| 26 retValue.attributeValue = vAttr.bstrVal; |
| 27 } |
| 28 else if (vAttr.vt == VT_I4) |
| 29 { |
| 30 retValue.attributeValue = std::to_wstring(vAttr.iVal); |
| 31 } |
| 32 return retValue; |
| 33 } |
OLD | NEW |