Getting text from elements without id or class name

c# html-agility-pack

Question

Using HTML Agility Pack, I'm attempting to parse HTML code. Is there a guide online, or can someone explain how to extract words from a picture?<td> that lacks a class and an ID?

    <table id="results-table">
    <tr class="row1">
    <td>Diode Zener Single 12V 5% 1W 2-Pin DO-41 Bulk</td> 
    ...

Each row has ten distinct<td> . Thanks!

1
0
10/3/2012 8:35:23 AM

Popular Answer

Try use this,XPATH to inquire of eachtd inside of youtable having id="results-table"

//table[@id='results-table']/tr/td

You may create an XPATH with the aid of the Firefox extension Firepath and then modify it from there.

example of a code

HtmlDocument doc = new HtmlDocument();
var fileName = @"..\..\..\docs\10960189.htm";
doc.Load(fileName);

var nodes = doc.DocumentNode.SelectNodes("//table[@id='results-table']/tr/td");

foreach (var node in nodes)
{
    Debug.WriteLine(node.InnerText);
}

HTH

3
6/9/2012 12:28:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow