| | |
Get all <img> Tags that are siblings?
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi all
I need to detect all image tags in a HTML document that are siblings:
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.
Josh
I need to detect all image tags in a HTML document that are siblings:
html Syntax (Toggle Plain Text)
<p> <img ../> <img ../> <img ../> </p> <p> <img ../> </p>
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.
Josh
•
•
Join Date: Dec 2007
Posts: 132
Reputation:
Solved Threads: 21
0
#2 Oct 19th, 2009
javascript Syntax (Toggle Plain Text)
var siblings=[] for( var i=0, limit=document.images.length-1; ++i) { if( document.images[i].parentNode===document.images[i+1].parentNode) siblings[siblings.length]=i; } alert( siblings.join("\n") );
•
•
Join Date: Dec 2007
Posts: 132
Reputation:
Solved Threads: 21
0
#3 Oct 19th, 2009
sorry, the for clause should be
javascript Syntax (Toggle Plain Text)
for( var i=0, limit=document.images.length-1; i < limit; ++i) ...
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#4 Oct 21st, 2009
Let's make an example that is similar to you
Now my code will be
Hope it will be okay.
Regards.
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<abc> <def> <img>1</img> <img>2</img> <img>3</img> </def> <ghi> <img>4</img> </ghi> <jkl/> </abc>
Now my code will be
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<xsl:template match="/"> <xsl:for-each select="//img[preceding-sibling::img or following-sibling::img]"> <xsl:value-of select="."></xsl:value-of> </xsl:for-each> </xsl:template>
Hope it will be okay.
Regards.
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
-1
#5 Nov 3rd, 2009
thanks for all for providing their suggestions and i was also trying for one like this
+++++++++++++++++++++++++++++
bandwidth test
Utah Web Design
+++++++++++++++++++++++++++++
bandwidth test
Utah Web Design
![]() |
Similar Threads
- ASP .NET hit counter? (ASP.NET)
- Images in signatures (Social Media and Online Communities)
- Preg match and replace for img urls (PHP)
- Quickie on positin:absolute (HTML and CSS)
- ermm hello (Community Introductions)
- No Posts? (DaniWeb Community Feedback)
- Frames of Pictures (C++)
- help! (Geeks' Lounge)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Nesting of xsl:key() within xsl:key() & combining results of xsl:key()
- Next Thread: Convert XML file to another XML file using XSLT
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt





