Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/xml: add an option to marshal line breaks and tabs literally #8166
(*Encoder).Encode and Marshal marshal line breaks as #xA; and tabs as #x9; http://play.golang.org/p/elBX-TVXBL It would be nice to have an option to marshal them (except in attributes) literally, like so, for example: encoder := xml.NewEncoder(...) encoder.Literal = true err := encoder.Encode(...) // Output: // <Foo>1 // 2 // 3</Foo>
> It should be possible to do this in the program by having the XML code write to a Writer that translates the byte sequences where appropriate. Well, here it is. Sometimes you want your XML to be human readable, and encoding ", ', \\, \n and \t as entities effectively prevents that. Also, I don't see any reason at all why they should be encoded, except in attribute values. Perhaps I should file another issue, titled "do not encode anything that needs not to be encoded". > It should be possible to do this in the program by having the XML code write to a Writer that translates the byte sequences where appropriate. There is a simpler and more efficient way - to fork the code and amend it. I don't want to go for it.