python and xml

Nibin V M nibinvm at gmail.com
Wed May 16 10:30:33 EDT 2012


thank you Stefan. but the XML output is assigned to a variable; how to
process the variable with XML contents?

On Wed, May 16, 2012 at 7:53 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:

> Nibin V M, 16.05.2012 16:16:
> > I am trying to use cPanel XML-API and every API call return data in XML
> > format. I would like to know how to manipulate the data here.
> >
> > For eg: How can I read the CPU load data from the below output
> >
> >
> >
>  <loadavg><one>0.00</one><five>0.00</five><fifteen>0.00</fifteen></loadavg><!--
> > whostmgrd -->
>
> Here's some untested code to print the text values:
>
>  import xml.etree.ElementTree as ET
>
>  loadavg = ET.fromstring('<loadavg><one>0.00</one><five>0.00</five>'
>                          '<fifteen>0.00</fifteen></loadavg>')
>
>  for interval_tag in ('one', 'five', 'fifteen'):
>      print(loadavg.findtext(interval_tag))
>
>
> Stefan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Regards....

Nibin.

http://TechsWare.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120516/25a990de/attachment.html>


More information about the Python-list mailing list