English 中文(简体)
HtmlAgilityPack选择末端不同的节点
原标题:HtmlAgilityPack selecting nodes with end different

我有这个代码。。。

<td class="alt1" id="td_threadtitle_335784">
<td class="alt1" id="td_threadtitle_342222">
<td class="alt1" id="td_threadtitle_554213">
<td class="alt1" id="td_threadtitle_31226">
<td class="alt1" id="td_threadtitle_9442">

问题是。。。

如何使用selectnodes或其他功能来选择ID。。。

我试着-

foreach (HtmlNode n in doc.DocumentNode.SelectNodes("//a[@id= td_threadtitle_ ]"))

但最终的数字是$%@#每件事。。。

[]秒

问题回答

[已解决]我只想选择td_threadtitle_

然后我用这个。。。

  `("//a[starts-with(@id, thread_title_ )]")`

效果很好!

我在这里也看到了这个代码。。

谢谢





相关问题
Stripping MS Word Tags Using Html Agility Pack

I have a DB with some text fields pasted from MS Word, and I m having trouble to strip just the , and tags, but obviously keeping their innerText. I ve tried using the HAP but I m not going in the ...

Select all <p> s from a Node s children using HTMLAgilityPack

I ve got the following code that I m using to get a html page. Make the urls absolute and then make the links rel nofollow and open in a new window/tab. My issue is around the adding of the attributes ...

Removing tags w/ prefix using HTML Agility Pack

I m trying to access tags with prefix using HAP but the following do not work (they return nothing): HtmlAgilityPack.HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//*[name() = sc:...

Order nodes by most images?

This might sound a bit complicated, but what I want to do is find all <a>s that contain <img>s such that the images that are in the same node with the greatest number of other images are ...

Trouble Scraping Web Page With Malformed Content

I have written c# code which utilizes the HtmlAgilityPack library in order to scrape a page located at: World s Largest Urban Areas (Page 2). Unfortunately the page consists of malformed content. ...

HTML Agility Pack - Select nodes after specific node

I asked the question in a codeplex discussion but I hope to get a quicker answer here at stackoverflow. So, I use HTML Agility Pack for HTML parsing in C#. I have the following html structure: <...

Html Agility Pack ends-with does not work

I tried to use ends-with in Html Agility Pack in the following mode: //span[ends-with(@id, Label2 )] and //span[ends-with(., test )] , but it does not work. All other functions, like starts-with ...

热门标签