• Post Reply Bookmark Topic Watch Topic
  • New Topic

prevent & to replace with &  RSS feed

 
david dabush
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am using Document in Java to create XML and in the end I am doing toString() to get the xml as a String.
the problem is that the xml contains a url and all the & become &.
how to prevent it from happening and not using : myxml.replaceAll("&ammp";, "&");


Thanks,
David
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is changing to what? The HTML tags seem to be interfering with your post. Don't post & but put the ‍ tag inside that tag. That is Zero Width Joiner, so you can write the tags and nobody will see the ZWJ.
 
salvin francis
Bartender
Posts: 1653
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you parsing the xml data ? Its simply a bad idea to think of XML as a string and modify it with replaceAll.

 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
& has to be escaped in XML, unless stuck in a CDATA.
So maybe your url should be in CDATA?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!