contains

Discussion in 'XML' started by Stephane Roux (HAbeTT), May 9, 2005.

  1. 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
     
    Stephane Roux (HAbeTT), May 9, 2005
    #1
    1. Advertising

  2. 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
     
    Stephane Roux (HAbeTT), May 9, 2005
    #2
    1. Advertising

  3. 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 |
    -----------------------
     
    Philippe Poulard, May 9, 2005
    #3
  4. /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
     
    David Carlisle, May 9, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian
    Replies:
    1
    Views:
    6,023
    kangfucius
    Feb 21, 2005
  2. James Dyer
    Replies:
    5
    Views:
    693
  3. KathyB
    Replies:
    3
    Views:
    2,435
    Axel Dahmen
    Jul 1, 2003
  4. Andrew Connell
    Replies:
    1
    Views:
    565
    Michael Evanchik
    Nov 10, 2003
  5. Dylan Phillips
    Replies:
    0
    Views:
    381
    Dylan Phillips
    Nov 13, 2003
Loading...

Share This Page