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:
--
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:
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())Thank you.--
Edit: Found a solution
print(soup.prettify(formatter=None))
with open(OUTPUTFILE, "w") as file:
#file.write(str(soup))
file.write(soup.prettify(formatter=None))
