building a string with newline characters 
Author Message
 building a string with newline characters

Hello,

How do I put in 'newline' characters inside or with a string so that when I
write the string out to a new file, the stuff is on seperate lines ?  see
below:

  std::string XML_temp = "";
  XML_temp = "<\?xml version= \"1.0\"\?>\";
  XML_temp += "<!DOCTYPE definition SYSTEM \"schema.dtd\" >\";
  XML_temp += "- - - - CONTENT HERE - - - - -\\n";

Thanks,
Randal

note:
before you tell me to use MSXML . . . thats my next step.



Mon, 02 Dec 2002 03:00:00 GMT  
 building a string with newline characters


Fri, 19 Jun 1992 00:00:00 GMT  
 building a string with newline characters
Thanks if you read this far....here is what you do - duh,

instead of using \\n  - use \n   you just dont "escape the escape"

  std::string XML_temp = "";
  XML_temp = "<\?xml version= \"1.0\"\?>\n";
  XML_temp += "<!DOCTYPE definition SYSTEM \"schema.dtd\" >\n";
  XML_temp += "- - - - CONTENT HERE - - - - -\n";
  XML_temp +=

Randal
Dallas,TX


Quote:
> Hello,

> How do I put in 'newline' characters inside or with a string so that when
I
> write the string out to a new file, the stuff is on seperate lines ?  see
> below:

>   std::string XML_temp = "";
>   XML_temp = "<\?xml version= \"1.0\"\?>\";
>   XML_temp += "<!DOCTYPE definition SYSTEM \"schema.dtd\" >\";
>   XML_temp += "- - - - CONTENT HERE - - - - -\\n";

> Thanks,
> Randal

> note:
> before you tell me to use MSXML . . . thats my next step.



Mon, 02 Dec 2002 03:00:00 GMT  
 building a string with newline characters

Quote:
> Thanks if you read this far....here is what you do - duh,

> instead of using \\n  - use \n   you just dont "escape the escape"

>   std::string XML_temp = "";
>   XML_temp = "<\?xml version= \"1.0\"\?>\n";
>   XML_temp += "<!DOCTYPE definition SYSTEM \"schema.dtd\" >\n";
>   XML_temp += "- - - - CONTENT HERE - - - - -\n";

You might be interested to know that you could re-write the above (probably
more efficiently) thus:

std::string XML_temp =
    "<\?xml version= \"1.0\"\?>\n"
    "<!DOCTYPE definition SYSTEM \"schema.dtd\" >\n"
    "- - - - CONTENT HERE - - - - -\n";

NeilB



Thu, 05 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Newline Character Stuck in Buffer?

2. newline character as a delimiter for hex records

3. Can fgets not detect newline character?

4. Newline Character

5. Problem with Newline Character

6. Socket recv and newline characters

7. newline characters

8. How do I check for a newline character ?

9. Newline Character in SDI Document

10. Visual C++ SDI Document Newline Character

11. Edit Box newline character

12. Newline character in Edit Controls

 

 
Powered by phpBB® Forum Software