We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example script from Sean: #!/usr/bin/python from lxml import etree from pykml.factory import KML_ElementMaker as KML TEXT_ELEMENTS = ['description', 'text', 'linkDescription', 'displayName'] def getXmlWithCDATA(obj, cdata_elements): # Convert Objectify document to lxml.etree (is there a better way?) root = etree.fromstring(etree.tostring(etree.ElementTree(obj))) #Create an xpath expression to search for all desired cdata elements xpath = '|'.join(map(lambda tag: '//kml:' + tag, cdata_elements)) results = root.xpath(xpath, namespaces = {'kml': 'http://www.opengis.net/kml/2.2'}) for element in results: element.text = etree.CDATA(element.text) return root kmlobj = KML.kml( KML.Document( KML.Placemark( KML.name('foobar'), KML.styleUrl('#big_label'), KML.description('<html>'), KML.text('<html>'), KML.linkDescription('<html>'), KML.displayName('<html>') ) ) ) kmlobj_with_cdata = getXmlWithCDATA(kmlobj, TEXT_ELEMENTS) print etree.tostring(kmlobj_with_cdata, pretty_print=True)
Original issue reported on code.google.com by tylerick...@gmail.com on 22 Feb 2012 at 12:56
tylerick...@gmail.com
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Original issue reported on code.google.com by
tylerick...@gmail.com
on 22 Feb 2012 at 12:56The text was updated successfully, but these errors were encountered: