<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<DIV><FONT face=Arial size=2>Right, stop and think about this. You're not
adding <a href="whatever"> before your <img> element because the
<a> element will ENCLOSE <img> like so:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><a href="whatever"><img
src="somethingelse"/></a></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>See? So <a> becomes the parent of
<img> so you need to remove <img> from the list and replace it with
<a> and add <img> as a child element of <a>. Seriously,
check out the documentation and read Java and XML by Brett McLaughlin and Jason
Hunter -- it won't take long and it'll save you a shedload of time in the long
run. ;-)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></DIV>
<DIV>=================================<BR>Bart Read<BR>Senior
Developer<BR>Abbotsbury Software Ltd<BR>Abbotsbury, DORSET DT3 4JT<BR>Tel: +44
(0) 1305 871543<BR>E-mail: <A
href="mailto:bart@wdi.co.uk">bart@wdi.co.uk</A><BR>=================================</DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=cedric@eolas.fr href="mailto:cedric@eolas.fr">Cédric Dumetz</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=jdom-interest@jdom.org
href="mailto:jdom-interest@jdom.org">jdom-interest@jdom.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, February 28, 2002 4:06
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [jdom-interest]
getElementsByTagName + insertBefore</DIV>
<DIV><BR></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial size=2>Sorry for my
ignorance</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial size=2>I finally do a
function like this</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2>******************************</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial size=2>private static
List getElementsByTagName(String name, Element elem) {<BR> Vector v = new
Vector(elem.getChildren(name));<BR> for (Iterator
it=elem.getChildren().iterator(); it.hasNext(); )
{<BR> v.addAll(getElementsByTagName(name,
(Element)it.next()));<BR> }<BR> return v;<BR>}</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2>********************************</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial size=2>and in my code I
do this call :</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2>***************************</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial size=2>
Element root = doc.getRootElement();</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial size=2>
List myIMG = getElementsByTagName("IMG", root)</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2>********************************</FONT></SPAN></DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=168265515-28022002><FONT face=Arial size=2>Now I have another
problem : how to insert an Element before another because I would like to
insert a <a href> tag before each <img> tag (I found all the
<img> tags with my method 'getElementsByTagName')</FONT></SPAN></DIV>
<HR>
<PRE><SMALL>
---------- Automatically inserted by WDI Mailserver ----------------
This message has been scanned for virus, trojans, illegal relays and
spam. If you have any comments, problems or questions please do not
hesitate to contact:
Abbotsbury Software Ltd
Tel: +44 1305 871543 Fax: +44 1305 871688
Email: postmaster@wdi.co.uk
Web: http://www.wdi.co.uk/virus.phtml
</SMALL></PRE></BLOCKQUOTE></BODY></HTML>