File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Java and XML problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Java and XML problems" Watch "Java and XML problems" New topic

Java and XML problems

Luis Jacho

Joined: May 04, 2013
Posts: 2
Just want to append a child to a xml document from NetBeans but i dont know whats wrong
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);

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

Joined: Mar 22, 2000
Posts: 12982
What is the source of this xxml.xml file you are trying to parse?

If you created it, did you use Microsoft Word?

Paul Clapham

Joined: Oct 14, 2005
Posts: 19693

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.
I agree. Here's the link:
subject: Java and XML problems
It's not a secret anymore!