Skip to content

Instantly share code, notes, and snippets.

@mvoong
Last active May 4, 2019 14:16
Show Gist options
  • Save mvoong/aeca83a660cbc8dee04c678a2f795af8 to your computer and use it in GitHub Desktop.
Save mvoong/aeca83a660cbc8dee04c678a2f795af8 to your computer and use it in GitHub Desktop.
Android namespace declaration in lxml
import lxml.etree as etree
tools_ns = "http://schemas.android.com/tools"
root = etree.Element("resources", nsmap={"tools": tools_ns})
root.attrib['{%s}ignore' % tools_ns] = 'MissingTranslation'
print(etree.tostring(root, encoding="unicode", pretty_print=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment