• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML parse error

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys i have a program which will generate a .xml file which has many fields got from db2 database. I am writing the .xml file using ISO-8859-1 format. But when i open the file in excel sheet it shows a message stating xml parse failed. what should i do for this. ? can anyone help me regarding this. I tried in utf-8 and utf-16 format still the file is not opening due to some junk characters in it. Please help me get rid of this problem .

Thanks in advance.
 
venkatesh warlu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am actually writing the xml file by appending the anchor tags using string buffer class. Tell me if this is the correct way to write the file or is there any other way i can create a proper xml file. I am getting data from db2 database as result set and storing it as strings. Now i need to write these strings in xml format. Please help me out of this. I am new to java and xml.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is nothing wrong with building an XML document with normal String methods, I do it all the time.

Several alternatives exist but directly writing Strings to an output stream is the fastest.

One source of junk characters is Microsoft word "smart punctuation" - what is writing the data into the database?

When I get bad characters in XML I use a programmer's editor to see the actual hex values in the document.

Bill
 
venkatesh warlu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks bill

Help me one more thing. Suppose i have the junk characters in one particluar string. Then is there any method to take out the ascii values alone from it. so that others get filtered out. I think regex will help me out. but i m unable to frmae out the code . please suggest some code for this.
 
venkatesh warlu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks bill

Help me one more thing. Suppose i have the junk characters in one particular string. Then is there any method to take out the ascii values alone from it. so that others get filtered out. I think regex will help me out. but i m unable to frame out the code . please suggest some code for this.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this example, we replace a crlf sequence with a single lf character



Where modS is the String to be modified and crlfRep is defined:



You need a Pattern (see java.util.regex) for every sequence that needs to be replaced. No new String is created if the Pattern is not found so this is faster than you might think.

Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic