Re: Jython or Pyton issue-- Kindly Help me....
Thanks for Help Sir, Am using for feature in tree.findall( .//{urn:ford/interface/VehicleOrder/LegacyFeatureMapping/v2}PortInstalledOptionFeature): ) Please sir help me Here also this findall Method is not return any list values. On Wednesday, October 15, 2014 1:03:00 PM UTC+5:30, Peter Otten wrote: Venugopal Reddy wrote: 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:VehicleLineId13001/a:VehicleLineId a:ModelYear2014/a:ModelYear a:LegacyColumn12/a:LegacyColumn a:LegacyValue178 /a:LegacyValue a:SalesCodeW78/a:SalesCode a:MappingId41859/a:MappingId a:MappingSeq0/a:MappingSeq a:MappingDirectionB/a:MappingDirection a:TargetFeature a:TargetCatgegory a:Id181/a:Id a:NameLIGHT TRUCK WHEELBASES/a:Name a:TypeP/a:Type a:FamilyCodeAA5/a:FamilyCode /a:TargetCatgegory a:OrderFeatureId15615/a:OrderFeatureId a:WersCodeAA5K8/a:WersCode a:OrderFeatureName178 /4521MM WHEELBASE /a:OrderFeatureName a:PIOfalse/a:PIO a:SummaryFeaturefalse/a:SummaryFeature /a:TargetFeature a:TargetFeature a:TargetCatgegory a:Id181/a:Id a:NameLIGHT TRUCK WHEELBASES/a:Name a:TypeP/a:Type a:FamilyCodeAA5/a:FamilyCode /a:TargetCatgegory a:OrderFeatureId15615/a:OrderFeatureId a:WersCodeAA5K8_second time/a:WersCode a:OrderFeatureName178 /4521MM WHEELBASE /a:OrderFeatureName a:PIOfalse/a:PIO a:SummaryFeaturefalse/a:SummaryFeature /a:TargetFeature /c:PortInstalledOptionFeature c:PortInstalledOptionFeature a:VehicleLineId13001/a:VehicleLineId a:ModelYear2014/a:ModelYear a:LegacyColumn12/a:LegacyColumn a:LegacyValue190 /a:LegacyValue a:SalesCodeW90/a:SalesCode a:MappingId41860/a:MappingId a:MappingSeq0/a:MappingSeq a:MappingDirectionB/a:MappingDirection a:TargetFeature a:TargetCatgegory a:Id181/a:Id a:NameLIGHT TRUCK WHEELBASES/a:Name a:TypeP/a:Type a:FamilyCodeAA5/a:FamilyCode /a:TargetCatgegory a:OrderFeatureId15616/a:OrderFeatureId a:WersCodeAA5MA/a:WersCode a:OrderFeatureName190 /4826MM WHEELBASE /a:OrderFeatureName a:PIOfalse/a:PIO a:SummaryFeaturefalse/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('') WersCodeList = tree.findall('./{urn:ford/VehicleOrder/LegacyFeatureMapping/v2.0}PortInstalledOptionFeature') Fatfile.write('\n') # 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. - The namespace is not correct - ./ finds only direct children Try something like for feature in tree.findall( .//{urn:ford/interface/VehicleOrder/LegacyFeatureMapping/v2}PortInstalledOptionFeature): code = feature.find( .//{urn:ford/VehicleOrder/LegacyFeatureMapping/v2.0}WersCode) print(code.text) Please please please help on this .. am struggling sice one week sir... ... and it's all your fault because you offered a task to do for you instead of some code we could help you fix. -- https://mail.python.org/mailman/listinfo/python-list
Re: Jython or Pyton issue-- Kindly Help me....
Ok, I will explain my problem in details : I have below XML: ?xml version=1.0? data country name=Liechtenstein rank1/rank year2008/year year2009/year gdppc141100/gdppc neighbor name=Austria direction=E/ neighbor name=Switzerland direction=W/ /country country name=Singapore rank4/rank year2011/year gdppc59900/gdppc neighbor name=Malaysia direction=N/ /country country name=Panama rank68/rank year2011/year gdppc13600/gdppc neighbor name=Costa Rica direction=W/ neighbor name=Colombia direction=E/ /country /data From I want output below format: CountrynameRankYeargdppc Liechtenstein 1 2008141100 Singapore 4 201159900 Panama 68 201113600 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.re...@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. -- https://mail.python.org/mailman/listinfo/python-list
Re: Jython or Pyton issue-- Kindly Help me....
) 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 rank1/rank year2008/year year2009/year gdppc141100/gdppc neighbor name=Austria direction=E/ neighbor name=Switzerland direction=W/ /country country name=Singapore rank4/rank year2011/year gdppc59900/gdppc neighbor name=Malaysia direction=N/ /country country name=Panama rank68/rank year2011/year gdppc13600/gdppc neighbor name=Costa Rica direction=W/ neighbor name=Colombia direction=E/ /country /data From I want output below format: CountrynameRankYeargdppc Liechtenstein 1 2008141100 Singapore 4 201159900 Panama 68 201113600 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. -- https://mail.python.org/mailman/listinfo/python-list
Jython or Pyton issue-- Kindly Help me....
Dear All, How to write a program for reading or parsing the XML file in Sub root Wise. For ex: Below XMl, I want to read/ parse first country details and here also two year tag values are there.. Here I need to read/parse first year value only measn '2008' Only..After that I need to read second country details. Please help me .. i am struggling to get this solution.. ?xml version=1.0? data country name=Liechtenstein rank1/rank year2008/year year2009/year gdppc141100/gdppc neighbor name=Austria direction=E/ neighbor name=Switzerland direction=W/ /country country name=Singapore rank4/rank year2011/year gdppc59900/gdppc neighbor name=Malaysia direction=N/ /country country name=Panama rank68/rank year2011/year gdppc13600/gdppc neighbor name=Costa Rica direction=W/ neighbor name=Colombia direction=E/ /country /data -- https://mail.python.org/mailman/listinfo/python-list
Hi Guys... Reading XML using Jython code
Am new to python and Jython... Kindly help me on My issue please ! My Issue is: XML parsing using Jython.. I am sucessfully reading XML file using xml.etree.ElementTree package .. But I have a issue in below scenario . this scenario my code is not working. In my XML file , One main node is there and Multiple child tags are there. But In Child tags , same name repeated twice (like subject tag repeated twice) This scenario , this package can not read .. How can I read very first come tag (means it should read first come subject node value only .leave the second come subject node value) Please help me on this -- https://mail.python.org/mailman/listinfo/python-list