File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replace Question Mark

 
Ragupathirajan Venkatesan
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I need to parse one xml file. while doing so I need to replace the ? with empty string.


for example,



please help to solve the issue. thanks in advance.


 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just skip the special meaning of ? using backslash '\'.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need to escape the backslash too, so try changing ? to \\?
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is simple as replacing each '?' with an empty string then there is no need for replaceAll(), just use


Edit : Thinking about this, it looks to me like the OP has parsed an XML file using the wrong character encoding and now need to get rid of the resulting '?' that are created when the encoder does not recognise some bytes as characters.
 
Ragupathirajan Venkatesan
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
Thanks a lot. It works for me.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic