I use HTMLAgility
to parse the HTML document
I downloaded DL from my project and from referenced
.
Now, all my needs are to parse this HTML (bottom):
& lt; HTML & gt; & Lt; Body & gt; // ...................... & lt; TDI id = 'image' & gt; & Lt; TR & gt; & Lt; TD & gt; Video codec & lt; / TD & gt; & Lt; TD colspan = 2 & gt; JPEG (8192 KBytes) & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Body & gt;
Now, I need to retrieve the video codec
from the above HTML and its value JPEG
.
I know that I can use HTMLAgility
, but how to do it?
var document = new HtmlDocument (); String html string = "& lt; tdi id = 'image' & gt;"; Document.LoadHtml (htmlString); // How to get the video codec and its value `JPEG '?
Any hints given is very appreciated
Edit:.
I was able to proceed slightly for the response of @itedi but was still stuck up.
var cells = document.DocumentNode // Manually use XPath instead of looping. Selection node (@ "// Table") .toList (); Var tbodies = cells.First () Selection nodes (@ "//"). ToList ();
Gives me all tobes
, but how do I print the value from it?
A very light way will use regex:
string s = @ "From & lt; tbody id = 'image' & gt; & lt; tr & gt; & lt; td & gt; video codec & lt; / td & gt; & lt; td colspan = 2 & gt; JPEG (8192 KBytes) & lt; / TD & gt; & lt; / TR & gt; & lt; / body & gt; "; Results above = Regex.Match ("LD; TD> Video codec ?? (+). "). group 1]; Returns: JPEG (8192 KBytes)
Comments
Post a Comment