[jdom-interest] Re: Adding String to Element where String contains an Element in String form

J S ladyslipper98201 at yahoo.com
Tue May 28 11:18:12 PDT 2002


I figured out how to do it.

The trick was:
//turn the title into an xml document   
List l = doc.getContents()
//detach each of the contents
List old = oldElement.getChildren();
l.addAll(old);

oldElement.removeChildren();
oldElement.setContent(l);

I am still running into the namespace problem but I
think for now I'll use a - instead of a : to avoid
namespace and then put the : back in on
transformation.


--- J S <ladyslipper98201 at yahoo.com> wrote:
> Hi,
> 
> I have <title id="2005"></title> as my xml.  
> 
> I do a java lookup getTitle(2005) and receive the
> following text: "<javacustomtag:GetName/> welcome"
> 
> Now I want to put this text into the xml so that it
> now looks like:
> 
> <title id="2005"><javacustomtag:GetName/>
> welcome</title>
> 
> The problem is that the <>s are being escaped into
> &lt; &gt; s
> 
> So here is my java code.
> 
> String topicTitle = "<javacustomtag:GetName/>
> welcome";
> Vector children = new Vector();
> children.add(topicTitle);
> List eChildren = e.getChildren();
> eChildren = e.getChildren();
> children.addAll(eChildren);
> e.removeChildren();
> e.setContent(children);
> 
> where e is a JDOM element with a string value of 
> 
> <title id="2005">
> <title>Hello</title>
> <title></title>
> <title></title>
> </title>
> 
> I want the result to be
> 
> <title id="2005">
> <javacustomtag:GetName/> welcome
> <title>Hello</title>
> <title></title>
> <title></title>
> </title>
> 
> Any ideas appreciated,
> 
> Jo


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the jdom-interest mailing list