• Post Reply Bookmark Topic Watch Topic
  • New Topic

need to maintain literal \"  RSS feed

 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. If anybody has a minute, this is an example of what i need to do...stream a simple xml...and piece together the xml string from various String objects...

String CustomerName = "<CustomerName>Joe Blow</CustomerName>";

String CustomerAddress = "<CustomerAddress xsi:nil=\"true\" ></CustomerAddress>";

String xmlcode=CustomerName + "\r\n" +
CustomerAddress + "\r\n" +
"END OF XML";

..xmlcode is streamed/processed...

The problem is maintaining the \"true\" literal from the CustomerAddress string when it is added to the xmlcode string to keep it form getting translated beforhand.

As it is above, the xmlcode string will look like this...

String xmlcode = <CustomerName>Joe Blow</CustomerName>
<CustomerAddress xsi:nil="true" ></CustomerAddress>
END OF XML";

the \'s are translated and gone when the CustomerAddress string object is added to the xmlcode String object. Then when the xmlcode string is written to the stream, it will terminate at the first quote before true becasue it no longer sees the quotes as literals..

Does anybody have a way to maintain the literal \"true\" so the xmlcode String will read like this?...

String xmlcode = <CustomerName>Joe Blow</CustomerName>
<CustomerAddress xsi:nil=\"true\" ></CustomerAddress>
END OF XML";

I've read versious things but i;'m getting burtied under a mountain of single quotes, double quotes, and backslashes with no good result. Thank you very much for your time and reading this.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this does it for future reference...

"<CustomerAddress xsi:nil=\\\"true\\\" ></CustomerAddress>";
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, you are producing well-formed XML, but something in your output process can't handle that and you need to insert extra characters to make it work? Something about that doesn't smell right to me. I would fix the output process rather than producing malformed XML that ends up being correct after the output process.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!