3

I have some XML like this:

<div>
    <sp>
        <speaker>Flores</speaker>
        <l part="y-ns" rend="ws-3">Es muchacho,<ref n="2" /> no te asombre.</l>
    </sp>
    <sp>
        <speaker>Comendador</speaker>
        <l part="y-ns" rend="ws-3">Cuando no sepa mi nombre,</l>
        <l>¿no le sobra el que me dan</l>
        <milestone type="new-stanza" />
        <l part="y-ne"> de Comendador Mayor?</l>
    </sp>
</div>

I want to find the l elements whose text is less than 50 characters. I think the problems are like like the first l, where there is some element in the middle. I tried to concatenate the strings, but I wasn't able to do it right. I have already tried this XPaths:

//l[string-length(./text())< 50]
//l[string-length(.//string(.)) < 50]
//l[string-length(concat(.//text())) < 100]

None works, that is why I came here :) Any idea?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
José
  • 533
  • 1
  • 4
  • 14

1 Answers1

3

Put point as string-length argument to use text of current l tag

//l[string-length(.) < 100]
splash58
  • 26,043
  • 3
  • 22
  • 34