该检查表ID条件语句 - ASP XML DOM [英] Conditional Statement that check the TABLE ID - ASP XML DOM

查看:355
本文介绍了该检查表ID条件语句 - ASP XML DOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有存储在 textResponse 称为变量从别的网站未来的HTML和我也有一个简单的ASP,XML DOM code的检查和输出通过的className表。

I have an HTML stored on the variable called textResponse coming from the other website and I also have a simple ASP-XML DOM code that check and output the table through className.

下面是HTML结构

<html>
   <head></head>
     <body>
       <table id="mytable" class="results">
           <tr>
               <td>Some Data</td>
           </tr>
       </table>
     </body>
</html>

和这里是ASP和XMLDOM code的检查和输出 TABLE 通过类属性

and here is the ASP and XMLDOM code that check and output the TABLE through class attribute

Dim HTMLDoc, XML
Dim URL, table

Set HTMLDoc = CreateObject("HTMLFile")
Set XML = CreateObject("MSXML2.ServerXMLHTTP")

URL = "www.sample.com" 
With XML
  .Open "GET", URL, False
  .Send
  HTMLDoc.Write .responseText
  HTMLDoc.Close
End With

For Each table In HTMLDoc.getElementsByTagName("TABLE")

If table.className = "results" Then
     tablestr = table.outerHTML
End If
Next

在code工作完全正常,但这个时候,我用表按ID属性要输出的表。是否有任何其他的方式,通过ID属性来检查和输出表?

the code works perfectly fine but this time, i want to output the table using TABLE by ID attribute. Is there any other way to check and output the TABLE through ID attribute?

推荐答案

我的方式得到了我的问题的答案,ATLEAST这将有助于其他人谁还不知道

I got the answers on my question by the way, atleast it will contribute to others who doesn't know yet

For Each table In HTMLDoc.getElementsByTagName("TABLE")
    If table.getAttribute("id") = "mytable" Then
        tablestr = table.outerHTML
    End If
Next

希望它可以帮助..:)

Hope it helps.. :)

这篇关于该检查表ID条件语句 - ASP XML DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆