<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=430425718-05052006><FONT face=Arial
color=#0000ff size=2>I'd first look at whether or not you need ANY kind of XML
processing for this. If all you are doing is replacing $REPLACE_THIS with some
string, then you could just get the template into a String object and
do</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=430425718-05052006><FONT face=Arial
color=#0000ff size=2>string.replaceAll("\$REPLACE_THIS",
replacementString);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=430425718-05052006><FONT face=Arial
color=#0000ff size=2>(because replaceAll expects a RegEx, you need to escape the
dollar sign)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=430425718-05052006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=430425718-05052006><FONT face=Arial
color=#0000ff size=2>Doing this wouldn't even require "tidying" up the
doc.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=430425718-05052006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> jdom-interest-bounces@jdom.org
[mailto:jdom-interest-bounces@jdom.org] <B>On Behalf Of </B>Leonardo
Barbosa<BR><B>Sent:</B> Friday, May 05, 2006 2:10 PM<BR><B>To:</B>
jdom-interest@jdom.org<BR><B>Subject:</B> [jdom-interest] Text
replacement<BR></FONT><BR></DIV>
<DIV></DIV>Hi!<BR><BR>I'm new to jdom and xml, so sorry if this is non
sense.<BR>I read a xml template (a html to be true, transformed to XML using
tidy) file from my client, and want to change all ocurrences of one text to
something else. It will probably be inside some javascript, something like
<BR><a href="#" onclick="javascript:openLink($REPLACE_THIS);"><BR><BR>bu
could be in the text of some <script> tag for
example:<BR><script><BR>funcion onclick(){<BR>
opeanUrl("REPLACE_THIS"); <BR>}<BR></script><BR><BR>There only one more
thing: It needs to be inside some tag, the one that defines the link
url:<BR><BR><chamada><BR>1
<a href="#" onclick="openLink($REPLACE_THIS);">click here</a>
<BR></chamada><BR><BR><chamada><BR>2
<a href="#"
onclick="openLink($REPLACE_THIS);">$REPLACE_THIS</a><BR></chamada><BR><BR><BR>Is
there a way to do this with jdom API, without getting all Descendents from the
tag <chamada> and looking inside its Text and Attributes ?<BR>something
like:<BR><BR> Iterator chamadaIterator =
root.getDescendants (new ElementFilter("chamada"));<BR>
while (chamadaIterator.hasNext()) {<BR>
Element chamadaTag =
(Element) chamadaIterator.next();<BR>
chamadaTag.setTextReplacement("$REPLACE_THIS", "
<A
href="http://www.thinkgeek.org">http://www.thinkgeek.org</A>");<BR>
}<BR><BR>I've searched the forum and found some ideas aboute
html entities, but it seams to be not the case, since I have one value for the
<SPAN class=def-word>whole </SPAN>document.<BR><BR>I no that it seeas to be
lazyness :-)<BR>But in fact I'm trying to avoid some desnecessary loop inside
all elements, all texts from theese elements, and all attributes from theese
elements. <BR><BR>Thanks in advance,<BR>Leonardo Barbosa<BR><A
href="mailto:lsbarbosa@gmail.com">lsbarbosa@gmail.com</A><BR><BR></BODY></HTML>