Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7651691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:34:13+00:00 2026-05-31T11:34:13+00:00

I built a Python script (with minidom) to manipulate the layout of an Android

  • 0

I built a Python script (with minidom) to manipulate the layout of an Android app, which is defined in an XML file. Widgets are elements in the android namespace, for example:

<TextView android:id="@+id/myId" android:text="..." />

Note the android:id attribute and its required format @+id/.... I didn’t find a way to pick that element with getElementById(). Maybe it’s because I don’t know minidom, but more likely it’s because I don’t understand XML namespaces deeply.

I remember that id is an attribute to uniquely identify an element in a tree. I never saw a namespaced ID, so my guess is that android:id isn’t really an ID, but just an attribute which happens to be called id in the android namespace. In this case there’s no way to getElementById, because it works with XML id’s. Currently I traverse the dom and check the android:id attribute to get my target element, but this technique is obviously less flexible than getElementById directly

Disclaimer: I tagged this with xslt because I think that xslt people can know the answer since they are used to working with XML and namespaces

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:34:14+00:00Added an answer on May 31, 2026 at 11:34 am

    OK – I found something else that may be of help to you. Apparently it depends on what has been listed of being of type “ID”. Where is that defin ed and can you influence it? I don’t know 🙁 But check How to set element's id in Python's xml.dom.minidom?

    See extract below from http://www.w3.org/TR/DOM-Level-2-Core/core.html

    getElementById introduced in DOM Level 2
    Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID.
    Note: The DOM implementation must have information that says which attributes are of type ID. Attributes with the name “ID” are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python script that uses built-in modules but also imports a number
All the Python built-ins are subclasses of object and I come across many user-defined
There are so many html and xml libraries built into python , that it's
So I wrote a Python script which does some simple stuff. It was originally
Using the python built-in profiler with a script runninng in one processor (and no
I have an .x3d code which references a python script. I am trying to
What is the cost of len() function for Python built-ins? (list/tuple/string/dictionary)
I'm wondering if there's a reason that there's no first(iterable) in the Python built-in
Does Python have a built-in, simple way of encoding/decoding strings using a password? Something
Using python 2.4 and the built-in ZipFile library, I cannot read very large zip

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.