Hello,
One more before I go to bed…
No matter what I try, BS turns the brackets of the LS string into "<" and ">" instead of keeping them as is:
Thank you.
--
Edit: Found a solution
One more before I go to bed…
No matter what I try, BS turns the brackets of the LS string into "<" and ">" instead of keeping them as is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from bs4 import BeautifulSoup soup = BeautifulSoup( open ( 'input.kml' , 'r' ), 'xml' ) LS = "<Style><LineStyle><color>FF0000FF</color><width>6</width></LineStyle></Style>" for ls in soup.find_all( "LineString" ): parent = ls.parent #BAD parent.insert(0,LS) #BAD parent.insert(0,LS.encode(formatter="html")) #BAD parent.insert(0,str(LS)) print (soup.prettify()) |
--
Edit: Found a solution
1 2 3 4 |
print (soup.prettify(formatter = None )) with open (OUTPUTFILE, "w" ) as file : #file.write(str(soup)) file .write(soup.prettify(formatter = None )) |