Forums Register Login
The character '' is an invalid XML character exception getting while export data in XML file
Dear All,

I am extract data from database and export in XML file.

If in the database table contains less than 8000 records then the xml generated successfully.

But if the record contains more than 8000 records while export data in xml file it is throwing the exception

ERROR [main] - Error in xmlExport
java.io.IOException: The character '' is an invalid XML character
at org.apache.xml.serialize.BaseMarkupSerializer.characters(Unknown Source)
at com.siemens.plmwbs.dao.ExportPlmWbsDao.generateXMLFile(ExportPlmWbsDao.java:137)
at com.siemens.plmwbs.dao.ExportPlmWbsDao.getFileData(ExportPlmWbsDao.java:252)
at com.siemens.plmwbs.exportwbs.PLMWbsExporter.generatePLMWBSXMLFile(PLMWbsExporter.java:100)
at com.siemens.plmwbs.exportwbs.PLMWbsExporter.main(PLMWbsExporter.java:67)

Below given the code:-

Please suggest how to fix this error.

Thanks in advance.

Sumanta Panda
You will have to find out the true identity of the illegal character and then figure out what is generating it.

The square you are seeing is just the operating system's attempt to show a character it doesnt have a font for.

If this was my problem I would catch the IO exception and dump the message as hex bytes. Hopefully the identity of the character will give you a clue as to where it comes from.

Try the toCharArray method to get the message characters and the Integer.toHexString( int ) method to get the hex representation.

What is the original source of the Strings in the database? If it is Word documents then "smart punctuation" may be your problem.

Dear William Brogden,

Thanks William Brogden for your response.The character ''is an invalid XML character exception issue has been solved.This issue happened because of''the table record.When i remove'' this record from table.It is working.

One more issue i am facing.

My table contains 82704 correct records.I didnt get any error/exception while export in xml file.

While export, few records is export in the xml file .But from the end few records is not exported.

While open the generated xml file in the end the error message is showing


Please note that the location of the xml file contains enough space.

But how many maximum record we export in the xml file at a time.

The generated xml file size is 44.1 mb.

Please suggest how i resolve this issue.

Thanks for the understaning.

Sumanta Panda

While open the generated xml file in the end the error message is showing

What program are you using to try to display this XML document?

While the text may take 44.1mb, if the program needs to create a DOM before displaying it, MUCH more memory will be needed. This because a DOM creates a new object for every data element in the document.

Dear William,

Thanks for your response.Sir i am begineer for writting xml program.
Could you please identity my mistake in the above given code and also suggest me what the piece of code i need to change so that it should work.

Thanks and Regards,
Sumanta Panda

The code you posted produces an XML file correctly, right? But then some other code fails to display that XML file because it's too large? Do I understand that correctly?

If that's the case, then the code you posted is correct code. The problem is with that other code which can't display a very large XML document. Although I wouldn't really be very concerned about that; there aren't any users who will want to display such a large document and look through it.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 4482 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 18, 2018 01:18:54.