<body>
<select name=”select1” value=”200”>
  <Option value =”4” name=”text1”href= "http://ddddd">文字1</Option>
  <Option value =”5” name=”text12”></Option> <select name=”select2” value=”33200”>
    <Option value =”4” name=”text1”href= "http://dddddddddd">文字2</Option>
    <Option value =”5” name=”text12”></Option>
 </select></select>
</body>前提:使用IID_IHTMLDocument2。
如何分别获取文字1和文字2 的href值
谢谢

解决方案 »

  1.   

    IHTMLDocument2::QueryInterface --> IHTMLDocument3
    IHTMLDocument3::getElementsByTagName("option") --> IHTMLElementCollection
    for (long i=0; i< IHTMLElementCollection::get_length; i++)
    {
      IHTMLElementCollection::item(i) --> IDispatch
      IDispatch::QueryInterface --> IHTMLOptionElement
      if (IHTMLOptionElement::get_text() == "文字1")
      {
        IHTMLOptionElement::QueryInterface --> IHTMLElement
        IHTMLElement::getAttribute("href") ----------------------> OK, href==http://ddddd
      }
    }
      

  2.   

    这段 HTML 本身就是畸形的,所以析取结果很有可能是不可靠的。