wood burning stoves*
The moose likes XML and Related Technologies and the fly likes Error processing resource while parsing XML with '&' symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Error processing resource while parsing XML with Watch "Error processing resource while parsing XML with New topic
Author

Error processing resource while parsing XML with '&' symbol

Sam Jimzz
Greenhorn

Joined: Apr 30, 2011
Posts: 28

Can any one tell me how to write a xml file while the content from the database contains XML-relevant
characters like '&' or '<'..

In the case of normal file writer concept i can write into xml file without any hassle..but while reading the file., Internet Explorer throws an error like Whitespace is not allowed at this location. Error processing resource 'file:///C:xxxxx/xxx.xml Line 202 where line 202 contains a field with " & " .


God Loves You and will never love you less.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Either escape those characters (escape "&" as "&amp;" and "<" as "&lt;") or make the text node be a CDATA section.

I'm not going to go into more details, this should have been in the first chapter of your basic XML resource.
Sam Jimzz
Greenhorn

Joined: Apr 30, 2011
Posts: 28

Could you tell me how to escape those special characters using java code while writing into file or reading from a file.?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I already did. Instead of writing a single "&" you have to write the string "&amp;", and so on. So if your text node looks like "A & B" then you have to write "A &amp; B". That's what "escaping" means.

But you might find it easier to just write each of your text nodes as CDATA sections.
Sam Jimzz
Greenhorn

Joined: Apr 30, 2011
Posts: 28

Alright Paul Clapham.. I got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error processing resource while parsing XML with '&' symbol
 
Similar Threads
Servlet Action currently Unavailable
i am getting error in hibernate
Aspose.Total Product Family Q3 2010 Released
Error displaying XML page
error in creating XML