"""
import sys
+from xml.sax.saxutils import escape
class KmlObject(object):
def to_kml(self):
- return self.render()
+ kml = self.OPEN_TAG
+ kml += self.render()
+ kml += self.CLOSE_TAG + "\n"
+ return kml
def render(self):
- kml = self.OPEN_TAG
- kml += self.text
+ kml = escape(self.text)
for c in self.children:
kml += c.to_kml()
-
- kml += self.CLOSE_TAG + "\n"
return kml
def render_to_stdout(self):
- if not (len(self.text) == 0):
- print self.text
+ if (len(self.text) > 0):
+ print escape(self.text)
for c in self.children:
c.print_kml()
<Document>"""
CLOSE_TAG = """</Document>
- </kml>"""
+</kml>"""
def __init__(self, initial_text=''):
super(Document, self).__init__(initial_text)
class RawText(KmlObject):
- pass
+
+ def to_kml(self):
+ return self.text
+
+ def print_kml(self):
+ if (len(self.text) > 0):
+ print self.text