2017-10-04 80 views
1

我有一個輸入標籤如何使用C++獲取輸入標記中的屬性值的文本?

<input class= " " size = " " read-only=" " value=" "> 

(我得到這個,當我一個IHTMLELEMENT對象上做一個get_innerHtml())。

使用的庫是ATL。
我需要提取值中的文本。有沒有一種方法可以使用api檢索文本?

調查詳情:

我已經使用getAttribute() API與屬性爲「價值」的嘗試。這會在變體中返回一個值「I4 = 0」。問題中的元素是一個「列表項目」。標籤爲「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); 
+0

如何以及在哪裏得到這個?你在用什麼庫?提供[mcve] – UnholySheep

+0

希望這樣更好。 – ghost

回答

0

您可以使用使用屬性爲 「價值」 的IHtmlElement中的getAttribute()API。

   CComBSTR bsProperty; 
       bsProperty = "value"; 
       pChild->getAttribute(bsProperty,0,&vtVariant); 
       bsValue1 = vtVariant.bstrVal; 
相關問題