Friday, May 10, 2013

(HtmlElement) Fail to move to next sibling

I have try to use NextSibling property to navigate on the next HTML tag name to check if the next sibling contains some innertext to move to next sibling.


This is my current code:



_wb2.DocumentCompleted += (sender2, e2) =>
{
textBox1.Text = "Application is scraping the results...Please wait...";
HtmlElementCollection href3 = _wb2.Document.GetElementsByTagName("dt");
//in foreach loop program will go trough all elements that contains tag name "input"
foreach (HtmlElement input in href3)
{
if (input != null && input.InnerText == "Dénomination :")
{
HtmlElement next = input.NextSibling;
if (next != null)
{
_list.Add(next.InnerText.ToString());
}
i++;
}
}
};



The structure of HTML is:



<dl>
<dt>Denomination :</dt>
<dd>Some text</dd>
</dl>



I want to store "Some text" from dd element in my list instance.


Any suggestion on this one?




Microsoft Student Parnter Microsoft Technology Associate





No comments:

Post a Comment