100715 File 100715 File 100715 File

match a value with a string containing that value using XPATH

35 Views Asked by At

I have this XML file :

<Archive Lot="1">
  <DOSSIER>
    <Identifiant>100715</Identifiant>
    <Personne>
      <LIBL>File</LIBL>
    </Personne>
  </DOSSIER>
<DOSSIER>
    <Identifiant>3455667</Identifiant>
    <Personne>
      <LIBL>File2</LIBL>
    </Personne>
  </DOSSIER>
</Archive>

I would like to match the node DOSSIER in the with a string that contains the value of Identifiant.

With the following request, it works :

Archive/DOSSIER[contains(Identifiant, "100715")]

But in my case, I want to match with a string that's not exactly identical but contains the node's value. By doing so, it doesn't match.

Archive/DOSSIER[contains(Identifiant, "100715_klingon_uiiu")]

I don't have a match. How do I go about it? I need to match a node in my XML with external information (a file name) whose value is not exactly identical. But the identifier is there. Thank you

1

There are 1 best solutions below

2
Daniel Haley On BEST ANSWER

It seems like you can just swap your contains() args around (because you want to check if the first argument string contains the second argument string)...

/Archive/DOSSIER[contains("100715_klingon_uiiu", Identifiant)]