How can I get the href attribute from the "a" tag?

zenfreak

Client
Регистрация
21.08.2013
Сообщения
249
Благодарностей
11
Баллы
18
Why I can't get the href attribute for the a tag like the code below?

Код:
HtmlElementCollection heCol = doc.FindElementsByAttribute("div", "class", "myAwesoneClass", "text")
string postAuthor = heCol.GetByNumber(5).FindChildByAttribute("a", "class", "anotherClass", "text", 0).href;
What would be a better approach?
 

zenfreak

Client
Регистрация
21.08.2013
Сообщения
249
Благодарностей
11
Баллы
18
I found the answer. I should use the GetAttribute method
Код:
string postAuthor = heCol.GetByNumber(5).FindChildByAttribute("a", "class", "anotherClass", "text", 0).GetAttribute("href");
 
  • Спасибо
Реакции: LightWood

LightWood

Moderator
Регистрация
04.11.2010
Сообщения
2 382
Благодарностей
915
Баллы
113

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)