3
我使用dom4j來解析AndroidManifestFile.xml。然而,我發現它奇怪地對待「android:xxx」屬性。具有限定名稱的dom4j attributeValue
例如:
<receiver android:name="ProcessOutgoingCallTest" android:exported="false"
android:enabled="false">
<intent-filter android:priority="1">
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
返回值e.attributeValue("android:exported")
將null
但是使用e.attributeValue("exported")
將獲得正確的字符串(但我不喜歡這種方式,因爲它可以匹配超過預期)。同時,e.attributeValue(new QName("android:exported"))
仍然是空字符串。
什麼是正確的方式來獲得屬性
是因爲它 「的xmlns:機器人=」?http://schemas.android.com/apk/res/android」在典型的AndroidManifest.xml定義 –
是。你只需要考慮如何使用'QName'和命名空間相關的東西。 – chenzhongpu