title: XSLT problem: Search in strings for substring "&quot;" or "&amp;#x003E;"
body: <p>I'm learning XSLT and at the moment I'm really stuck and can't find a solution. I really would appreciate if you could help me with this.
  Beneath you can find an example</p>
  
  <p>value of $string:</p>
  
  <pre><code>&amp;amp;#x003C;img src=&amp;quot;Afbeeldingen_Hotpot/beer.jpg&amp;quot; alt=&amp;quot;afbeelding van een beer&amp;quot; title=&amp;quot;beer&amp;quot; width=&amp;quot;170&amp;quot; height=&amp;quot;144&amp;quot; style=&amp;quot;display:block; margin-left:auto; margin-right:auto; text-align:center;&amp;quot; style=&amp;quot;float:center;&amp;quot; /&amp;amp;#x003E;
  </code></pre>
  
  <p>My goal is to filter out the height of the image... In this example "144".
  the functx:index-of-string I got from this website: <a href="http://www.xsltfunctions.com/xsl/functx_index-of-string.html" rel="nofollow">http://www.xsltfunctions.com/xsl/functx_index-of-string.html</a></p>
  
  <p>This the XSLT code I now use:</p>
  
  <pre><code>    &lt;xsl:variable name="positionHeight" as="xs:integer"&gt;&lt;xsl:value-of select="functx:index-of-string($string,'height=') + 8"/&gt;&lt;/xsl:variable&gt;
      &lt;xsl:variable name="partStringHeight" as="xs:string"&gt;&lt;xsl:value-of select="substring($string,$positionHeight)"/&gt;&lt;/xsl:variable&gt;
      &lt;xsl:variable name="lengthHeight" as="xs:integer"&gt;&lt;xsl:value-of select="functx:index-of-string($partStringHeight,'style=' - 3)"/&gt;&lt;/xsl:variable&gt;
      &lt;xsl:variable name="height" as="xs:string"&gt;&lt;xsl:sequence select="substring($partStringHeight,1,$lengthHeight)"/&gt;&lt;/xsl:variable&gt;
  </code></pre>
  
  <p>Beneath the XSLT code I want to use, but gives an error because the index-of-string for "&quot;" is zero".</p>
  
  <pre><code>    &lt;xsl:variable name="positionHeight" as="xs:integer"&gt;&lt;xsl:value-of select="functx:index-of-string($string,'height=') + 8"/&gt;&lt;/xsl:variable&gt;
      &lt;xsl:variable name="partStringHeight" as="xs:string"&gt;&lt;xsl:value-of select="substring($string,$positionHeight)"/&gt;&lt;/xsl:variable&gt;
      &lt;xsl:variable name="lengthHeight" as="xs:integer"&gt;&lt;xsl:value-of select="functx:index-of-string($partStringHeight,'&amp;quot;' - 1)"/&gt;&lt;/xsl:variable&gt;
      &lt;xsl:variable name="height" as="xs:string"&gt;&lt;xsl:sequence select="substring($partStringHeight,1,$lengthHeight)"/&gt;&lt;/xsl:variable&gt;
  </code></pre>
  
  <p>Is there a way to get the index of a substrings like:</p>
  
  <pre><code>&amp;quot; and &amp;amp;#x003E;
  </code></pre>
  
  <p>Because I have many strings were I need the height but where "style=" does not occur..</p>