CodeBeatz
CodeBeatz

Reputation: 1981

How can I get in XPath all element with multiple child conditions?

Ciao,

I'm working with XPath and I need to retrieve all elements by specific conditions.

Below one example of my XML document:

<?xml version="1.0" encoding="UTF-8"?>
<persone>
             
    <persona>
        <nome>Mario</nome>
        <cognome>Rossi</cognome>
    </persona>

    <persona>
        <nome>Mario</nome>
        <cognome>Bianchi</cognome>
    </persona>

    <persona>
        <nome>Marco</nome>
        <cognome>Verdi</cognome>
    </persona>
             
</persone>

I need to create an XPath query that return all elements with these two conditions true:

How can I achieve this goal?

Upvotes: 2

Views: 935

Answers (1)

CodeBeatz
CodeBeatz

Reputation: 1981

I've resolved my problem using a query like this:

//persona[nome[text()='Mario'] and cognome[text()='Bianchi']]

Upvotes: 1

Related Questions