hi all,

how to parse an xml attributes using python. I want to read or extract msg values from xml using python.

         <msg timestamp="20160817 12:46:42.520" level="INFO">Average : 0.14 %
CPU (%)
10 Aug 07:00
2
12 Aug 07:00
maximum 5.17
average 0.13</msg>

Your pasting of xml is a mess:)
The best is to use Beautiful Soup/lxml.
E.g

from bs4 import BeautifulSoup

xml ='''\
<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Hello</to>
  <from>wold</from>
  <msg timestamp="20160817 12:46:42.520" level="INFO">Info on CPU</msg>
</note>'''

#soup = BeautifulSoup(open("your.xml"), 'html.parser') #Read from a file
soup = BeautifulSoup(xml, 'html.parser')
msg = soup.find('msg')
print(msg.text) #--> Info on CPU
print(msg.get('timestamp')) #--> 20160817 12:46:42.520

Now i use html.parser which in the standard library.
If lxml is installed,use always this parser soup = BeautifulSoup(xml, 'lxml-xml') or BeautifulSoup(xml, 'lxml')
Not that matter for you,because you have not use old BS.
New is BS you have to specify as parser as i have shown here.

Now you have posted this under Hardware and Software Cloud-based Applications
Which is not what this is about.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.