Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid custom XML parser fails to resolve android namespace
    text
    copied!<p>I would like to get the correct way of parsing custom android tags with an XmlResourceParser. I am using Eclipse 3.6 with the android plug-in, and I would like some attributes like the <code>name</code> be expanded with the full string from <code>strings.xml</code>.</p> <p>Here is the <code>index.xml</code> which is being parsed in the <code>res/xml/</code> folder.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Index xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;Sheet shortName="o_2sq" android:name="@string/o_2sq" instructions="" /&gt; &lt;/Index&gt; </code></pre> <p>Here is the file <code>strings.xml</code> in the <code>res/values/</code> folder</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string name="o_2sq"&gt;Organize two squares&lt;/string&gt; &lt;/resources&gt; </code></pre> <p>and the code fragment that parses the first <code>index.xml</code> with an XmlResourceParser:</p> <pre><code>String name = xpp.getAttributeValue(null, "android:name"); String shortName = xpp.getAttributeValue(null, "shortName"); </code></pre> <p>The variable <code>name</code> contains <code>null</code>, but <code>shortName</code> contains <code>"o_2sq"</code>. I also tried the following without success:</p> <pre><code>String name = xpp.getAttributeValue("android", "name"); </code></pre> <p>What is the correct way of writing the sentence so that the variable name would contain <code>"Organize two squares"</code> ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload