contains

  • Thread starter Stephane Roux (HAbeTT)
  • Start date
S

Stephane Roux (HAbeTT)

Hello,

I'm an XML newbie, trying things through perl. My question must be
simple and is related to XPath.

I've got
<?xml version="1.0" encoding="iso-8859-1"?>
<base>
<arret ref="10400390" public="yes" ville="Paris">
<objet>Droits d'auteur, oeuvre cinématographique, contrat de
cession</objet>
</arret>
<arret ref="37484740" public="yes" ville="Paris">
<objet>Droit des marques, commercialisation de denrées sous une
marque, faute contractuelle, accord de coexistence de marques,
contrefaçon, concurrence déloyale</objet>
</arret>
<arret ref="38748168" public="no" ville="Paris">
<objet>Rupture abusive de contrat de distribution</objet>
</arret>
</base>

I want an XPath to catch the <arret> when objet contains the word
"marques".

I've tried /base/arret/objet[contains(text(),marques)=true] but i'm
too much an XML dummy for this to work.

Can anyone help me ?
 
S

Stephane Roux (HAbeTT)

Stephane Roux (HAbeTT) said:
I want an XPath to catch the <arret> when objet contains the word
"marques".

I've tried /base/arret/objet[contains(text(),marques)=true] but i'm
too much an XML dummy for this to work.

OK, I found it by myself,
/base/arret/objet[contains(text(),'marques')]/parent::*

Right ?
 
P

Philippe Poulard

Stephane said:
In <[email protected]>, Stephane Roux (HAbeTT)
wrote:

I want an XPath to catch the <arret> when objet contains the word
"marques".

I've tried /base/arret/objet[contains(text(),marques)=true] but i'm
too much an XML dummy for this to work.


OK, I found it by myself,
/base/arret/objet[contains(text(),'marques')]/parent::*

Right ?

hi,

try this :
/base/arret[contains(objet/text(),'marques')]

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
D

David Carlisle

/base/arret/objet[contains(text(),'marques')]/parent::*

that works but rather than going down and back up again it's probably
more natural to write an Xpath that more closely models your natural
language description
I want an XPath to catch the <arret> when objet contains the word
"marques".

/base/arret/[contains(objet,'marques')]

So long as each arret only has one arret child, as this form only checks
the first.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,843
Latest member
WizcraftEntertainmentAgen

Latest Threads

Top