我有一个 HtmlElementCollection,我想使用 Linq 获取其 id 包含另一个列表中的 id 的 HtmlElements 列表。
所以我尝试了一些方法,但都没有成功。我从集合中获取一个列表并尝试对其进行过滤。
这是部分 id 的列表。元素 id 是不同的,它们的 id 与此列表相对应,并在开头加上一些看似随机的数字。
string[] ids = {"btadminh_struct.description",
"thtmlb_textView_6",
"thtmlb_textView_7",
"btadminh_struct.object_id",
"thtmlb_textView_12",
"zbtsalesset_struct.po_number_sold",
"thtmlb_textView_17",
"thtmlb_textView_21",
"thtmlb_textView_24",
"btcustomerh_z_followupdate",
"thtmlb_textView_29",
"btrefobjmain_ibibase",
"btrefobjmain_ibinstancedesc",
"btpartnerserviceto_struct.description_name",
"btpartnerset_contact_name",
"zzericempresp_struct.partner_no",
"zbtcsrowner_struct.partner_no",
"btcustomerh_struct.zcomments",
"thtmlb_textView_19",
"btadminh_servicecontractdescr",
"btcustomerh_zcontracttype_descr",
"btrefobjmain_network_id",
"btrefobjmain_node_id",
"btrefobjmain_site_id"};
元素 id 如下所示:
"C29_W87_V88_btrefobjmain_network_instance",
"C29_W87_V88_btrefobjmain_network_id__items",
"C29_W87_V88_btrefobjmain_network_id",
"C29_W87_V88_btrefobjmain_network_id-btn",
"C29_W87_V88_btrefobjmain_network_id__key",
"C29_W87_V88_thtmlb_label_2",
"C29_W87_V88_btrefobjmain_service_id__items",
"C29_W87_V88_btrefobjmain_service_id",
"C29_W87_V88_btrefobjmain_service_id-btn",
"C29_W87_V88_btrefobjmain_service_id__key",
"C29_W87_V88_thtmlb_label_3",
"C29_W87_V88_btrefobjmain_networkadap_id__items",
"C29_W87_V88_btrefobjmain_networkadap_id",
"C29_W87_V88_btrefobjmain_networkadap_id-btn",
"C29_W87_V88_btrefobjmain_networkadap_id__key",
所以我将我的收藏放入一个可以查询的列表中。
var elems = doc.All.Cast<HtmlElement>();
我尝试过不同的方法,但没有一个非常有效。我还想使用 Linq 并避免丑陋的 2-D foreach 循环。
有任何想法吗?