XPath HtmlElementCollection: Get Only 1st Level Elements

zenfreak

Client
Регистрация
21.08.2013
Сообщения
249
Благодарностей
11
Баллы
18
Having this as an example I'm trying to build an XPath expression for creating a HtmlCollection.

Код:
<AAA>
    <BBB>
        <CCC>
    <CCC>
    <DDD>
        <EEE>
            <CCC>
    <FFF>
    <GGG>
    <CCC>
I want to get all CCC elements that are direct descendants of AAA

So the result should be only elements on rows 4 and 10 and NOT elements on rows 3 and 7

I know this is something simple but I'm pretty new to XPath and still learning
 

amyboose

Client
Регистрация
21.04.2016
Сообщения
2 312
Благодарностей
1 190
Баллы
113
//AAA/CCC
 

zenfreak

Client
Регистрация
21.08.2013
Сообщения
249
Благодарностей
11
Баллы
18
Последнее редактирование:

amyboose

Client
Регистрация
21.04.2016
Сообщения
2 312
Благодарностей
1 190
Баллы
113
/AAA/CCC
 

zenfreak

Client
Регистрация
21.08.2013
Сообщения
249
Благодарностей
11
Баллы
18


Ok, this is the real problem. I need to get all c-wiz elements from the selected div but without getting the red one. Using your response, it should be as follows:

HtmlElementCollection cwz = div2.FindChildrenByXPath("/div/c-wiz");

But this doesn't get any elements at all while using "//div/c-wiz" gets all the c-wiz elements
 

amyboose

Client
Регистрация
21.04.2016
Сообщения
2 312
Благодарностей
1 190
Баллы
113
I can't help you without the website
so you can send me file with html text
 

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