0

How can I get information out of all td tags in Classen = "string_14" so that I can store it away clean without html code in.

I have thought about this:

enter code here
<table class="string_14">
                <tbody><tr>
                    <td>Postadr.:</td> 
                    <td class="tab_space">Stenslivegen 67, 2817 Gjøvik</td> 
                </tr>
                <tr>
                    <td>Telefon:</td> 
                    <td class="tab_space">611 80 710</td>
                </tr>

                <tr>
                    <td>Mobil:</td> 
                    <td class="tab_space">957 92 455</td>
                </tr>
                </tbody>
                </table>

And my code to get it looking like this today, I want help with is to write xpath to name =? how should I write to get a single td.

        HtmlDocument doc = new HtmlDocument();
        doc.Load(new StringReader(result));
        HtmlNode root = doc.DocumentNode;


        List<string> list = new List<string>();
        foreach (HtmlNode div in root.SelectNodes("//div[@class='biz_list']"))
        {
            string name = doc.DocumentNode.SelectNodes("//d[@class='string_14']/@tr");
            list.Add(name);
            string att = div.OuterHtml;
            list.Add(att);
        }

What I want out of this is I'm going to scrape a page and then the LATE stage I'll save this down to the xml file.

4

1 回答 1

1

我想你想要的是这样的:

HtmlNodeCollection collection = doc.DocumentNode.SelectNodes("//table[@class='string_14']//td[@class='tab_space']");

您可以查阅XPath 教程以了解更多信息。

于 2013-03-19T16:50:05.917 回答