Hi all

I need to detect all image tags in a HTML document that are siblings:

  <img ../>
  <img ../>
  <img ../>
  <img ../>

In the example above I need to detect the first three img tags, but not the fourth.

In contrary, I also need to detect the img tags that do NOT have direct img siblings.

Sadly I have no idea how to do this. Any hint, please? Thanks.

var siblings=[]
for( var i=0, limit=document.images.length-1; ++i)
 if( document.images[i].parentNode===document.images[i+1].parentNode)
alert( siblings.join("\n") );

sorry, the for clause should be

for( var i=0, limit=document.images.length-1; i < limit; ++i)

Let's make an example that is similar to you


Now my code will be

<xsl:template match="/">
        <xsl:for-each select="//img[preceding-sibling::img or following-sibling::img]">
            <xsl:value-of select="."></xsl:value-of>

Hope it will be okay.