[jdom-interest] How to replace an Element with Text?

Brad Cox bcox at virtualschool.edu
Sun Mar 28 09:38:01 PST 2004

Thanks! Found it in the b10 release. I was using b9 which has no such 
method. Will try that now.

At 10:15 AM -0600 3/28/04, Bradley S. Huffman wrote:
>Brad Cox writes:
>>  Thanks! That was exactly the problem. But the solution still eludes.
>>  After rewriting like this: (no such class as Parent, and Element
>>  doesn't do indexOf()):
>>	    Element parent = e.getParent();
>>	    List siblings = parent.getChildren();
>>	    int index = siblings.indexOf(e);
>>               Text t = new Text("#radioElement('"+nameAttr+"'
>>  '"+valueAttr+"' '"+buf+"')");
>>	    siblings.set(index, t);
>>  I get this error:
>>  org.jdom.IllegalAddException: Filter won't allow index 0 to be set to
>>  org.jdom.Text at
>>  org.jdom.ContentList$FilterList.set(ContentList.java:835)
>>  Looks like JDOM is onto this and is determined to stop it. Time for
>>  bigger hammers? ;)
>Skip using getChildren which gives a filtered view of only Elements and use
>the indexOf defined on Element.
>     Element parent = e.getParent();
>     int index = parent.indexOf(e);
>Go Pokes!!!
>To control your jdom-interest membership:

Brad J. Cox, PhD, 703 361 4751, http://virtualschool.edu
        http://virtualschool/ale Action Learning Environment
http://virtualschool.edu/mybank Digital Rights Management System
    http://virtualschool.edu/jco Java Cryptographic Objects (JCO)
   http://virtualschool.edu/jwaa Java Web Application Architecture (JWAA)
  http://virtualschool.edu/java+ Java Preprocessor (Java+)

More information about the jdom-interest mailing list