Return multiple attributes using XPATH

Asked

Viewed 251 times

4

How can I return multiple attributes using the xpath language? For example this xml:

<utilizador>
        <nome>Rui</nome>
        <contacto>91xxxxxxx</contacto>
        <localidade>Viseu</localidade>
        <cesto>
            <encomenda refidprod="rlg05" estado="enviado" data="13-01-2014"/>
            <encomenda refidprod="hifi02" estado="enviado" data="1-10-2014"/>
        </cesto>
        <cestohist>
            <encomendas refidprod="tv02" estado="entregue" data="29-11-2014"/>
        </cestohist>
<utilizador>

How to return the values of the attributes of the orders, both basket and basket?

Cumpz

1 answer

4


In the XML example, it would be //utilizador/cesto | //utilizador/cestohist to return any of the two attributes.

Explaining: Each of the //utilizador/cesto and //utilizador/cestohist return only one attribute, the operator | is used to join the two results.

  • Thank you, that’s just what I needed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.