I have a xml file from a page which shows correctly on the text editor but once I use readlines(), I only get one line. I assume this means the line separator being used isn’t recognized by python but it is by gedit.
I want to do a split() on it to get the data correctly but how can I see what line separator is being used in the file?
As is pointed out in the comments, if it’s xml, just hand it to an XML parser like ElementTree or lxml. Newlines shouldn’t matter in XML.
For information, using
open("thefile.xml", "rU")will open it with universal newline support, so Python will recognise\n,\ror\r\nas newline markers.