Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java and XML problems

 
Luis Jacho
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just want to append a child to a xml document from NetBeans but i dont know whats wrong
try{
DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document futxml = dBuilder.parse(new File("xmlsrc/xxml.xml"));
if( futxml.hasChildNodes()) System.out.println("SI");
Element hijo = futxml.createElement(jTextField2.getText().trim());
// Text text = futxml.createTextNode(jTextArea.getText().trim());
// hijo.appendChild(text);
futxml.appendChild(hijo);


This is my error org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
please help !!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the source of this xxml.xml file you are trying to parse?

If you created it, did you use Microsoft Word?

Bill
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And as always when you get an exception: what line of code threw the exception? Don't just ignore the stack trace, it tells you that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic