Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > contains

Reply
Thread Tools

contains

 
 
Stephane Roux (HAbeTT)
Guest
Posts: n/a
 
      05-09-2005
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 ?

--
|":._.:"| http://habett.com/
| (=) | http://habett.org/
..\./|\./. My employer has my views
 
Reply With Quote
 
 
 
 
Stephane Roux (HAbeTT)
Guest
Posts: n/a
 
      05-09-2005
In <>, 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 ?


--
|":._.:"| http://habett.com/
| (=) | http://habett.org/
| .:':. | I send the energy to my enemy
 
Reply With Quote
 
 
 
 
Philippe Poulard
Guest
Posts: n/a
 
      05-09-2005
Stephane Roux (HAbeTT) wrote:
> In <>, 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 |
-----------------------
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      05-09-2005

/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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mozilla : 'the document contains no data' error C. Tobini Firefox 8 05-04-2005 02:36 PM
The document contains no date messag? del Firefox 1 12-22-2004 12:12 AM
'The document contains no date' message in Firefox Corse Firefox 5 09-30-2004 02:24 AM
"This documents contains no data" Lysiane Firefox 1 09-29-2004 01:20 AM
Regex problem, match if line contains <a>, unless it also contains <b> James Dyer Perl 5 02-20-2004 12:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57