I would like to use lxml to change some attribute values of an android xml file.
For example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/version_label"
android:layout_marginLeft="5sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="version"/>
</LinearLayout>
I want to change the “android:text” value, but
textViewTagNode.attrib['android:text'] = "new value"
couldn’t work, neither
textViewTagNode.set('android:text', 'new value')
could work. All I get is “Invalid attribute name u’android:text’ “
I know it’s the namespace problem, but I don’t know how to fix it.
Thanks a lot.
Your key is not
'android:text'but'{http://schemas.android.com/apk/res/android}text'