TypeError Element object is not subscriptable

0 votes

HI, It's 2 Am i am asking this question, 

i  have xml file which is very huge, i wanted to fetch particular value from the tag which i shown below. 

i wanted to fetch the   <name>1.Start Up</name> from the below xml. kindly help me with exact python code.

i was using 

from xml.dom import minidom




-<process xmlns="http://www.blueprism.co.uk/product/process" name="WW Process 3 (Query Regional Catalogue)" id="d15c64dd-1644-45b2-a3dd-8e584d379669">

-<process name="WW Process 3 (Query Regional Catalogue)" byrefcollection="true" narrative="Searches for items not added in the WW catalogue and adds them on Mondays and Tuesdays" bpversion="" version="1.0">



<endpoint narrative=""/>

-<subsheet published="False" type="Normal" subsheetid="a6eff02a-a8f5-49bb-bb20-d4216b513122">

       <name>1.Start Up</name>




Feb 18, 2020 in Python by Bharati
• 120 points

1 answer to this question.

0 votes

Hey Bharti,

You can get some idea from the below example. 

  • This mainly happens with functions return different data types according to the parameters given. The best way to avoid this is to use type() function to determine the return value’s data type and act accordingly

  1. x = fun() #function whose return data type is unknown
  2. if type(x) == int:#if the return value is an integer
  3. #do this
  4. elif type(x) == str:#if the return value is a string
  5. #do this

If the error has occurred inside the function you need to check your code to ensure it’s working properly.

More about non-subscriptable error (TypeError)

Python will throw a TypeError if you try to access a non-subscriptable in a way that you access a string or array object (or any other type of subscriptable object) .

Here a string object subscripted

  1. >>> x = 'this is subscriptable'
  2. >>> x[0]
  3. >>> 't'

Some common non-subscriptable object types are int, float, bool and None

  1. >>> y = 123 #an integer
  2. >>> y[0] # will result an error
  3. Traceback (most recent call last):
  4. File "<pyshell#29>", line 1, in <module>
  5. y[0]
  6. TypeError: 'int' object is not subscriptable
  7. >>>

This type of errors happen when you use the same variable to store different type of data types throughout your code and you eventually lost track of the data type the variable currently has.

The solution is either to check the variable carefully throughout the code or to use different variables to store values with different data types if memory usage is not an issue.


  1. >>> x = '10' #x is a string
  2. >>> print(x)
  3. 10
  4. >>> x = int(x) #x is now a int
  5. >>> print(x)
  6. 10
  7. >>> x[0] # will result an error
  8. Traceback (most recent call last):
  9. File "<pyshell#29>", line 1, in <module>
  10. y[0]
  11. TypeError: 'int' object is not subscriptable
  12. >>>
answered Feb 18, 2020 by Gitika
• 65,970 points

Related Questions In Python

0 votes
1 answer

print(instance(0).id) TypeError: 'list' object is not callable

Hey @Suraj, For me its working fine. ...READ MORE

answered Jan 18, 2019 in Python by Priyaj
• 58,140 points
0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

answered Feb 9, 2019 in Python by Omkar
• 69,170 points
0 votes
1 answer

i am normalizing the data set iris in python and get the error ::TypeError: 'numpy.float64' object is not callable

TRY THIS   #Nomalisation for i in names:     print(i)   ...READ MORE

answered Aug 20, 2019 in Python by Noel Deepak Palle
0 votes
1 answer

Python error "'Series' object is not callable "

Try this: df['ln_returns'] = np.log(df['Close_mid']/df['Close_mid']) df['Close_mid'](1)) doesn't seem to ...READ MORE

answered Jul 22, 2019 in Python by Greg
0 votes
1 answer

TypeError: 'AxesSubplot' object does not support indexing

Hello , If you plot multiple subplots, the plt.subplots() returns ...READ MORE

answered May 7, 2020 in Python by Niroj
• 82,880 points
+1 vote
1 answer

Error:<map object at 0x7fa3435f3048> is not JSON serializable

Hello @kartik, map() in Python 3 is a generator ...READ MORE

answered Jul 3, 2020 in Python by Niroj
• 82,880 points
0 votes
1 answer

Django object is not JSON serializable

Hello @kartik, simplejson and json don't work with django objects well. Django's ...READ MORE

answered Aug 7, 2020 in Python by Niroj
• 82,880 points
0 votes
1 answer

'tuple' object is not callable

Hey, @There, This kind of error happens once ...READ MORE

answered Aug 13, 2020 in Python by Rajiv
• 8,910 points
0 votes
3 answers

TypeError: 'module' object is not callable

Solve By Calling with Module Name Another solution to the TypeError: 'module' object ...READ MORE

answered Jan 4 in Python by Carlos
0 votes
1 answer