Forum Discussion

sanj's avatar
sanj
Super Contributor
9 years ago
Solved

xpath can help you when contains does not work!

Look at the following text Expected - En savoir plus sur l'aide avec un fauteuil roulant à l'aéroport. Actual - En savoir plus sur l'aide avec un fauteuil roulant à l'aéroport. I tried using conta...
  • groovyguy's avatar
    groovyguy
    9 years ago

    Relative XPATH has made my life a bit easier. 

     

    Let's say you have the following XML Structure

     

    <Parent>

          <Child1>

                <DataPiece>A</DataPiece>

          </Child1>

          <Child2>

                <DataPiece>B</DataPiece>

          </Child2>

          <Child3>

                <DataPiece>C</DataPiece>

                <DataPiece2>1</DataPiece2>

          </Child3>

    </Parent>

    Let's say you want Child3, DataPiece2.

    Normally you have to use //Parent/Child3/DataPiece2. That's listing out the entire XPATH from start to finish. That can get cumbersome really quickly.

    A relative xpath would instead be
    //DataPiece2

    This is really helpful, but you have to be careful in your response that DataPiece2 doesn't show up at multiple levels. 

     


    Does that help at all?