Android: How to inject a element into another element in XML?

If I understand what you are looking to do, then internal (parsed) general entities might help you achieve what you are looking for.

An example of how you can define the value “Francesco” as an entity called “auth” and then use it in your XML:

<?xml version="1.0"?>
<!DOCTYPE doc [
  <!ENTITY auth "Francesco">
]>
<doc>
  <string name="author">&auth;</string>
  <string name="about_application">Author: &auth;</string>
</doc>

When read by an XML parser, the document will be parsed and evaluated, or “seen”, as:

<?xml version="1.0"?>
<doc>
  <string name="author">Francesco</string>
  <string name="about_application">Author: Francesco</string>
</doc>

Leave a Comment