我有一个input标签
<input class= " " size = " " read-only=" " value=" ">
(当我在IHTMLELEMENT
对象上执行get_innerHtml()
时,我得到了这个)。
使用的库是ATL。
我需要提取值中存在的文本。有没有一种方法可以让我使用api检索文本?
调查详情:
我已经尝试使用getAttribute()
接口,并将属性设置为"value“。这将在变量中返回一个值"I4=0“。所讨论的元素是一个"list-item“。标签为"LI“。Get_innerText
api给了我一个垃圾值。
注意:外部Html值为:
<li class=" "id= " "><input class= " " size= " " read-only=" " value=" "></li>
代码如下:
CComBSTR bsValue = NULL;
pHtmlElement->get_innerText(&bsValue);
char* innerText = convertBSTRToCharPtr(bsValue);
CString cstring(innerText);
发布于 2017-10-06 16:56:06
您可以在IHtmlElement上使用getAttribute()接口,并将属性用作"value“。
CComBSTR bsProperty;
bsProperty = "value";
pChild->getAttribute(bsProperty,0,&vtVariant);
bsValue1 = vtVariant.bstrVal;
https://stackoverflow.com/questions/46559137
复制相似问题