Jython or Pyton issue-- Kindly Help me....

Venugopal Reddy venugopal.reddy at tspl.com
Tue Oct 14 05:46:44 EDT 2014


Ok, I will explain my problem in details :

I have below XML:

<?xml version="1.0"?> 
<data> 
    <country name="Liechtenstein"> 
        <rank>1</rank> 
        <year>2008</year> 
        <year>2009></year> 
        <gdppc>141100</gdppc> 
        <neighbor name="Austria" direction="E"/> 
        <neighbor name="Switzerland" direction="W"/> 
    </country> 
    <country name="Singapore"> 
        <rank>4</rank> 
        <year>2011</year> 
        <gdppc>59900</gdppc> 
        <neighbor name="Malaysia" direction="N"/> 
    </country> 
    <country name="Panama"> 
        <rank>68</rank> 
        <year>2011</year> 
        <gdppc>13600</gdppc> 
        <neighbor name="Costa Rica" direction="W"/> 
        <neighbor name="Colombia" direction="E"/> 
    </country> 
</data> 


>From I want output below format:

Countryname    Rank    Year    gdppc 
Liechtenstein   1      2008    141100 
Singapore       4      2011    59900 
Panama          68     2011    13600

Please help how to do it..


On Monday, October 13, 2014 9:14:27 PM UTC+5:30, Ian wrote:
> On Mon, Oct 13, 2014 at 5:39 AM, Venugopal Reddy
> 
> <venugopal.reddy at tspl.com> wrote:
> 
> > Dear All,
> 
> >
> 
> > How to write a program for reading or parsing the XML file in Sub root Wise.
> 
> 
> 
> I don't know what "Sub root Wise" is. You can find an overview of
> 
> Python's XML parsing interfaces at
> 
> https://docs.python.org/2/library/xml.html. I would recommend using
> 
> the ElementTree API unless you have a specific reason to use something
> 
> else.



More information about the Python-list mailing list