[jdom-interest] Error org.jdom.IllegalNameException

Elliotte Rusty Harold elharo at metalab.unc.edu
Fri Nov 14 07:00:09 PST 2003


At 3:53 AM -0800 11/14/03, Moipone Mocoancoeng wrote:
In my program I extract text from one of the element in my xml 
document and I need to change the root element of the xml document to 
the text that I've extracted from one of the element in the doc

[CODE]

Element rootElement = (Element) xmlObject.getElement();

Element element= rootElement.getChild("Element");

String text= element.getText();

rootElement.setName(text);

[/CODE]

I get an error [I]The name "Internal Training"(which is the text 
returned) is not legal for JDOM/XML elements: XML names cannot 
contain the character " "

How do I remove the characters "".

Remove all white space  from the text before assigning it to the 
element's name.


-- 

   Elliotte Rusty Harold
   elharo at metalab.unc.edu
   Effective XML (Addison-Wesley, 2003)
   http://www.cafeconleche.org/books/effectivexml
   http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA



More information about the jdom-interest mailing list