Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79135
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-10-14 22:42 -0700 |
| References | <91eb3378-958d-45e0-8741-a800ae681260@googlegroups.com> <mailman.14825.1413215053.18130.python-list@python.org> <552277f6-fb5b-44de-a0d4-7c7fe480d265@googlegroups.com> <mailman.14843.1413283448.18130.python-list@python.org> |
| Message-ID | <0c8200cc-5ae7-4fd9-9dd6-903802fc5bb7@googlegroups.com> (permalink) |
| Subject | Re: Jython or Pyton issue-- Kindly Help me.... |
| From | Venugopal Reddy <venugopal.reddy@tspl.com> |
Actuvally am having below XML File:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<c:RetriveByVehicleLineModelYearResponse xmlns:a="urn:ford/VehicleOrder/LegacyFeatureMapping/v2.0" xmlns:b="urn:ford/VehicleOrder/SingleOrderEdit/v1.0" xmlns:c="urn:ford/interface/VehicleOrder/LegacyFeatureMapping/v2">
<c:PortInstalledOptionFeature>
<a:VehicleLineId>13001</a:VehicleLineId>
<a:ModelYear>2014</a:ModelYear>
<a:LegacyColumn>12</a:LegacyColumn>
<a:LegacyValue>178 </a:LegacyValue>
<a:SalesCode>W78</a:SalesCode>
<a:MappingId>41859</a:MappingId>
<a:MappingSeq>0</a:MappingSeq>
<a:MappingDirection>B</a:MappingDirection>
<a:TargetFeature>
<a:TargetCatgegory>
<a:Id>181</a:Id>
<a:Name>LIGHT TRUCK WHEELBASES </a:Name>
<a:Type>P</a:Type>
<a:FamilyCode>AA5</a:FamilyCode>
</a:TargetCatgegory>
<a:OrderFeatureId>15615</a:OrderFeatureId>
<a:WersCode>AA5K8</a:WersCode>
<a:OrderFeatureName>178 /4521MM WHEELBASE </a:OrderFeatureName>
<a:PIO>false</a:PIO>
<a:SummaryFeature>false</a:SummaryFeature>
</a:TargetFeature>
<a:TargetFeature>
<a:TargetCatgegory>
<a:Id>181</a:Id>
<a:Name>LIGHT TRUCK WHEELBASES </a:Name>
<a:Type>P</a:Type>
<a:FamilyCode>AA5</a:FamilyCode>
</a:TargetCatgegory>
<a:OrderFeatureId>15615</a:OrderFeatureId>
<a:WersCode>AA5K8_second time</a:WersCode>
<a:OrderFeatureName>178 /4521MM WHEELBASE </a:OrderFeatureName>
<a:PIO>false</a:PIO>
<a:SummaryFeature>false</a:SummaryFeature>
</a:TargetFeature>
</c:PortInstalledOptionFeature>
<c:PortInstalledOptionFeature>
<a:VehicleLineId>13001</a:VehicleLineId>
<a:ModelYear>2014</a:ModelYear>
<a:LegacyColumn>12</a:LegacyColumn>
<a:LegacyValue>190 </a:LegacyValue>
<a:SalesCode>W90</a:SalesCode>
<a:MappingId>41860</a:MappingId>
<a:MappingSeq>0</a:MappingSeq>
<a:MappingDirection>B</a:MappingDirection>
<a:TargetFeature>
<a:TargetCatgegory>
<a:Id>181</a:Id>
<a:Name>LIGHT TRUCK WHEELBASES </a:Name>
<a:Type>P</a:Type>
<a:FamilyCode>AA5</a:FamilyCode>
</a:TargetCatgegory>
<a:OrderFeatureId>15616</a:OrderFeatureId>
<a:WersCode>AA5MA</a:WersCode>
<a:OrderFeatureName>190 /4826MM WHEELBASE </a:OrderFeatureName>
<a:PIO>false</a:PIO>
<a:SummaryFeature>false</a:SummaryFeature>
</a:TargetFeature>
</c:PortInstalledOptionFeature>
</c:RetriveByVehicleLineModelYearResponse>
</soapenv:Body>
</soapenv:Envelope>
============================
My expected Output is:
WersCode
AA5K8
AA5MA
============== For this I have used below Code:
mport glob
import xml.etree.ElementTree as ET
Fatfile = open('#Var_SOE_VLIS_Response_Output\\Sales_to_Wers_Code2.txt', 'a')
try:
tree = ET.parse('#Var_ENG_Response_Files\\SoapResponse1.xml')
Fatfile.write('1111')
WersCodeList = tree.findall('./{urn:ford/VehicleOrder/LegacyFeatureMapping/v2.0}PortInstalledOptionFeature')
Fatfile.write('\n2222')
# x = len(WersCodeList)
# Fatfile.write(x)
Fatfile.write('\n333')
for WersCode in WersCodeList :
Fatfile.write('\n444')
WersCode = WersCode.find('.//{urn:ford/VehicleOrder/LegacyFeatureMapping/v2.0}WersCode')
Fatfile.write('\n')
Fatfile.write(WersCode.text)
except :
Fatfile.write(' \nsorry')
Fatfile.write(' \nSuccess')
====
But I could not able to get the WersCode List using Findall.
Please please please help on this .. am struggling sice one week sir...
On Tuesday, October 14, 2014 4:14:19 PM UTC+5:30, Peter Otten wrote:
> Venugopal Reddy wrote:
>
>
>
> > 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..
>
>
>
> Read up on elementtree:
>
>
>
> http://pymotw.com/2/xml/etree/ElementTree/parse.html
>
>
>
> You can load the data from the file with parse(), get the countries with
>
> findall(), the name with country_node.attrib["name"], and rank, year and
>
> gdppc with country_node.find("rank").text etc.
>
>
>
> If you run into problems come back with some code of yours.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Jython or Pyton issue-- Kindly Help me.... Venugopal Reddy <venugopal.reddy@tspl.com> - 2014-10-13 04:39 -0700
Re: Jython or Pyton issue-- Kindly Help me.... Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-13 09:43 -0600
Re: Jython or Pyton issue-- Kindly Help me.... Venugopal Reddy <venugopal.reddy@tspl.com> - 2014-10-14 02:46 -0700
Re: Jython or Pyton issue-- Kindly Help me.... Peter Otten <__peter__@web.de> - 2014-10-14 12:43 +0200
Re: Jython or Pyton issue-- Kindly Help me.... Venugopal Reddy <venugopal.reddy@tspl.com> - 2014-10-14 22:42 -0700
Re: Jython or Pyton issue-- Kindly Help me.... Peter Otten <__peter__@web.de> - 2014-10-15 09:32 +0200
Re: Jython or Pyton issue-- Kindly Help me.... Venugopal Reddy <venugopal.reddy@tspl.com> - 2014-10-15 01:35 -0700
Re: Jython or Pyton issue-- Kindly Help me.... Peter Otten <__peter__@web.de> - 2014-10-15 11:04 +0200
csiph-web