• 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

need to maintain literal \"

 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this does it for future reference...

"<CustomerAddress xsi:nil=\\\"true\\\" ></CustomerAddress>";
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic