/me nods...
Does the XML file format even care, at all, about newlines? My vague recollection is that it does not. Why can’t you just read the file, use an s///g... regex to stomp them all out, and process the resulting string? (For most computers these days, processing several megabytes “as a string” is no big deal anymore.)
| |
Does the XML file format even care, at all, about newlines?
It depends what you mean.
To XML, newlines and carriage returns do not have special meaning. Stripping them from the document will not affect the validity of the document.
On the other hand, it will change the values of text nodes and attribute nodes. (Upd: Not completely true: See Re^7 ) That may or may not be desirable. The OP indicated he only wanted to remove <CR><LF> pairs and leave lone <LF> behind, which can be done using your technique.
Update: Replaced bad example with better explanation.
| [reply] |
| [reply] [d/l] |
I don't think it does, and I've started to work with it that way. Makes it a tad hard to read (for verifying my program), but once I've coded it, what do I care? Thank you for your response!
Jen, if your computer was a person I'd shoot it in the face.
| [reply] |
You can always "pretty print" it. XML::Twig installs xml_pp that does just that. Note that it adds spaces which you might have to trim out later if you pass the prettied version to your parser.
| [reply] [d/l] |