Zuned Ahmed
Zuned Ahmed

Reputation: 1387

find xpath for sibling node

I want to get the value of name where map is anything. I dont want iterate and then find. Is there any way we can write xpath for the same?

What will be the xpath for node which is having map = sec2? Please find the xml below.

 <section-meta-data>
            <section>
                <name>Applicant Info</name>
                <map>sec1</map>
            </section>
            <section>
                <name>prior-insurance-coverage</name>
                <map>sec3</map>
            </section>
            <section>
                <name>hipaa-guarantee-issue-coverage</name>
                <map>sec2</map>
            </section>
            <section>
                <name>medical-info</name>
                <map>sec7</map>
            </section>
            <section>
                <name>medications</name>
                <map>sec4</map>
            </section>
        </section-meta-data>

Upvotes: 0

Views: 279

Answers (1)

Wayne
Wayne

Reputation: 60414

Use the following expression:

/section-meta-data/section[map='sec2']/name

Upvotes: 1

Related Questions