Archivos para ‘HtmlAgilityPack’

6 junio 2011

Eliminación de nodos con HtmlAgilityPack

por auraham

HtmlNodeCollection tables = doc.DocumentNode.SelectNodes("//table");

// Validacion de tabla nula
if (tables != null)
	doc.LoadHtml(tables[0].OuterHtml);

// Recorrido de la tabla
foreach (HtmlNode tr in doc.DocumentNode.SelectNodes("//tr"))
{
	// Coleccion de columnas
	HtmlNodeCollection cols = tr.SelectNodes("td");

	
	// Elimina la etiqueta bold y br
	cols[0].RemoveChild(cols[0].SelectNodes("b")[0]);
	cols[0].RemoveChild(cols[0].SelectNodes("br")[0]);

	string valor = cols[0].InnerHtml;
	
}

Seguir

Get every new post delivered to your Inbox.