Skip to content

[xml] XMLNS prefix is not pre-declared in xpath query #2766

@guxiaonian

Description

@guxiaonian

Hello there:
I want to locate the xmlns:android location of the following XML file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
         package="com.a.b">

        <application
             android:allowBackup="true"
             android:icon="@mipmap/ic_launcher"
             android:label="@string/app_name"
             android:roundIcon="@mipmap/ic_launcher_round"
             android:supportsRtl="true"
             android:theme="@style/AppTheme">
         <activity android:name=".MainActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />

                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
     </application>

</manifest>

My current approach is:

//manifest[contains(@xmlns:android,'http://schemas.android.com/apk/res/android')]

But there is an error in Xpath, can you tell me the correct way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugPMD crashes or fails to analyse a file.in:xpathRelating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions