使用C#在html中搜索特定标签 [英] Search Specific tag in html using c#

查看:146
本文介绍了使用C#在html中搜索特定标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html页面,其中有很多标签.我只想使用一些特殊的标签数据.例如,示例页面具有5个html table(带有in table的表)标记,并且只想使用3个table标记数据.

I have a html page there is lots of tag. i want to just use some particular tag data . For Example page have 5 html table(table with in table) tag and want to just use 3 table tag data.
how can i do this

推荐答案

在哪里以及如何使用它?

元素可以使用其 ID 进行标识.

例如,如果您的一个表的ID为table1,
在JavaScript中,您可以使用
访问table元素
Where and how do you want to use it?

Elements can be identified using their ID.

For example, if one of your table has an id table1,
in JavaScript, you can access the table element using
var tableVariable1 = document.getElementById("table1");


如果具有runat server标记,则可以在后面的C#代码中进行访问.只需使用它的ID并按点,您将获得各种可用的属性,方法和事件.

如果这样做没有帮助,请在问题中添加更多详细信息.


You can access the same in C# code behind, if you have runat server tag to it. Just use it''s id and press dot you will get various properties, methods and events available to it.

If this doesn''t help, please add more details to your question.


您可以使用DOM读取HTML文件
You can use DOM for reading HTML file
XmlDocument comHTML = new XmlDocument();
comHTML.Load("FilePath");
//Search for Specific tag
XmlNodeList xNodeList = xdHtml.GetElementByTagName("TagName");
if (xNodeList.Count == 0)
   //Tag Not Exist
else
   //Tag Exist


这篇关于使用C#在html中搜索特定标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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