сохраняю наработки связанные с работой над xml документами

This commit is contained in:
rzaitov 2013-11-14 20:00:41 +04:00
parent cf255b7b1b
commit 91b91a867d
3 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import xml.etree.ElementTree as eT
androidNs = 'http://schemas.android.com/apk/res/android'
eT.register_namespace('android', androidNs)
tree = eT.parse('data.xml')
root = tree.getroot()
print root.attrib
root.set('myAtr', 'myValue')
root.set('{{{0}}}myAtr'.format(androidNs), '777')
root.set('android:MyAttribute', 'Rustam')
tree.write('output.xml', xml_declaration=True, encoding='utf-8', method="xml")
print root.tag

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="DroidApp.DroidApp">
<uses-sdk />
<application android:label="DroidApp">
</application>
</manifest>

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:MyAttribute="Rustam" myAtr="myValue" package="DroidApp.DroidApp" android:myAtr="777" android:versionCode="1" android:versionName="1.0">
<uses-sdk />
<application android:label="DroidApp">
</application>
</manifest>