Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

Java and XML problems

Luis Jacho
Greenhorn

Joined: May 04, 2013
Posts: 2
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

Joined: Mar 22, 2000
Posts: 12760
    
    5
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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: http://aspose.com/file-tools
 
subject: Java and XML problems
 
Similar Threads
XML question
Bulk XML messages
Struts Form issue
Change the element tag names in XML