[jdom-interest] Text replacement
Leonardo Barbosa
lsbarbosa at gmail.com
Fri May 5 11:10:08 PDT 2006
Hi!
I'm new to jdom and xml, so sorry if this is non sense.
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
<a href="#" onclick="javascript:openLink($REPLACE_THIS);">
bu could be in the text of some <script> tag for example:
<script>
funcion onclick(){
opeanUrl("REPLACE_THIS");
}
</script>
There only one more thing: It needs to be inside some tag, the one that
defines the link url:
<chamada>
1 <a href="#" onclick="openLink($REPLACE_THIS);">click here</a>
</chamada>
<chamada>
2 <a href="#" onclick="openLink($REPLACE_THIS);">$REPLACE_THIS</a>
</chamada>
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 ?
something like:
Iterator chamadaIterator = root.getDescendants(new
ElementFilter("chamada"));
while (chamadaIterator.hasNext()) {
Element chamadaTag = (Element) chamadaIterator.next();
chamadaTag.setTextReplacement("$REPLACE_THIS", "
http://www.thinkgeek.org");
}
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 whole document.
I no that it seeas to be lazyness :-)
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.
Thanks in advance,
Leonardo Barbosa
lsbarbosa at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20060505/39155199/attachment.htm
More information about the jdom-interest
mailing list