I cant see the wood for the trees here..... help

I got this big string of xml from a url which is of data associated to a 
boat and many boats
the tags are 'VehicleRemarketingBoatLineItem' which is the overall tag for 
a boat set of data whcih contains various tags and tag groups, so

    dom = minidom.parse(urllib2.urlopen(url))
    stuff{}  // I want a dict of pairs
    for x in dom.getElementsByTagName('VehicleRemarketingBoatLineItem'):   
//1
        for node in 
x.getElementsByTagName('VehicleRemarketingBoat'):          //2
            name_list = node.getElementsByTagName('MakeString')
            for n in name_list:
                name = n.childNodes[0].nodeValue
                stuff['name'] =  name

if I raise NameError at for loop 1 I get only the last boat and if at 2 I 
get only the 1st boat so I dont think I am indexing the dict population?
any light shone on this would be much appreciated

the xml stream can be seen from this url 
https://services.boatwizard.com/bridge/events/ae0324ff-e1a5-4a77-9783-f41248bfa975/boats?status=on
 


this is the whole whole sorry lump of code so far (its a lot)

    from xml.dom import minidom
    from xml.dom.minidom import parseString
    url = 
"https://services.boatwizard.com/bridge/events/ae0324ff-e1a5-4a77-9783-f41248bfa975/boats?status=on";

    dom = minidom.parse(urllib2.urlopen(url))

    stuff = {}
    for x in dom.getElementsByTagName('VehicleRemarketingBoatLineItem'):
        for node in x.getElementsByTagName('VehicleRemarketingBoat'):
            name_list = node.getElementsByTagName('MakeString')
            for n in name_list:
                name = n.childNodes[0].nodeValue
                stuff['name'] =  name
            year_list = node.getElementsByTagName('ModelYear')
            for y in year_list:
                year = y.childNodes[0].nodeValue
                stuff['year'] = year
            model_list = node.getElementsByTagName('Model')
            for m in model_list:
                model = m.childNodes[0].nodeValue
                stuff['model'] = model
            length_group = node.getElementsByTagName('BoatLengthGroup')
            for x in length_group:
                n_l = node.getElementsByTagName('BoatLengthCode')[:1]
                for l in n_l:
                    length_code = l.childNodes[0].nodeValue
                    stuff['length_code'] = length_code
                nlm = node.getElementsByTagName('BoatLengthMeasure')[:1]
                for lm in nlm:
                    nominal_length = lm.childNodes[0].nodeValue
                    stuff['nominal_length'] = nominal_length
                loa_list = node.getElementsByTagName('BoatLengthCode')[:2]
                for loa in loa_list:
                    loa_code = loa.childNodes[0].nodeValue
                    stuff['loa_code'] = loa_code
                loa_measure_list = 
node.getElementsByTagName('BoatLengthMeasure')[:2]
                for lm in loa_measure_list:
                    loa_measure = lm.childNodes[0].nodeValue
                    stuff['loa_measure'] = loa_measure
                l_o_list = node.getElementsByTagName('BoatLengthCode')[:3]
                for loo in l_o_list:
                    length_overall_code = loo.childNodes[0].nodeValue
                    stuff['length_overall_code'] = length_overall_code

                l_o_measure_list = 
node.getElementsByTagName('BoatLengthMeasure')[:3]
                for lo in l_o_measure_list:
                    length_overall_measure = lo.childNodes[0].nodeValue
                    stuff['length_overall_measure'] = length_overall_measure
            bridge_list = 
node.getElementsByTagName('BridgeClearanceMeasure')
            for bl in bridge_list:
                bridge_clearance = bl.childNodes[0].nodeValue
                stuff['bridge_clearance'] = bridge_clearance
            beam_list  = node.getElementsByTagName('BeamMeasure')
            for bm in beam_list:
                beam = bm.childNodes[0].nodeValue
                stuff['beam'] = beam
            fuel_list  = 
node.getElementsByTagName('FuelTankCapacityMeasure')
            for f in fuel_list:
                fuel_capacity = f.childNodes[0].nodeValue
                stuff['fuel_capacity'] = fuel_capacity
            hold_list  = 
node.getElementsByTagName('HoldingTankCapacityMeasure')
            for h in hold_list:
                hold_capacity = f.childNodes[0].nodeValue
                stuff['hold_capacity'] = hold_capacity
            water_list  = 
node.getElementsByTagName('WaterTankCapacityMeasure')
            for w in water_list:
                water_capacity = w.childNodes[0].nodeValue
                stuff['water_capacity'] = water_capacity
            cat_code_list  = node.getElementsByTagName('BoatCategoryCode')
            for c in cat_code_list:
                category_code = c.childNodes[0].nodeValue
                stuff['category_code'] = category_code
            boat_class_group = node.getElementsByTagName('BoatClassGroup')
            for x in boat_class_group:
                bcc1 = node.getElementsByTagName('BoatClassCode')[:1]
                for b in bcc1:
                    boat_class_code = b.childNodes[0].nodeValue
                    stuff['boat_class_code'] = boat_class_code
                pbci = 
node.getElementsByTagName('PrimaryBoatClassIndicator')[:1]
                for p in pbci:
                    primary_boat_class_indicator = p.childNodes[0].nodeValue
                    stuff['primary_boat_class_indicator'] = 
primary_boat_class_indicator
                bcc2 = node.getElementsByTagName('BoatClassCode')[:2]
                for b in bcc2:
                    second_boat_class_code = b.childNodes[0].nodeValue
                    stuff['second_boat_call_code'] = second_boat_class_code
                sbci = 
node.getElementsByTagName('PrimaryBoatClassIndicator')[:2]
                for p in sbci:
                    secondary_boat_class_indicator = 
p.childNodes[0].nodeValue
                    stuff['secondary_boat_class_indicator'] = 
secondary_boat_class_indicator
            cruise_list = node.getElementsByTagName('CruisingSpeedMeasure')
            for cr in cruise_list:
                cruising_speed = cr.childNodes[0].nodeValue
                stuff['cruising_speed'] = cruising_speed
            engine_list = 
node.getElementsByTagName('TotalEnginePowerQuantity')
            for e in engine_list:
                engine_power = e.childNodes[0].nodeValue
                stuff['engine_power'] = engine_power
            berth_list = node.getElementsByTagName('NumberOfBerthsNumeric')
            for b in berth_list:
                number_berths = b.childNodes[0].nodeValue
                stuff['number_berths'] = number_berths
            cabin_list = node.getElementsByTagName('NumberOfCabinsNumeric')

            for b in berth_list:
                number_berths = b.childNodes[0].nodeValue
                stuff['number_berths'] = number_berths
            cabin_list = node.getElementsByTagName('NumberOfCabinsNumeric')
            for b in cabin_list:
                number_cabins = b.childNodes[0].nodeValue
                stuff['number_cabins'] = number_cabins
            cabin_headroom_list = 
node.getElementsByTagName('CabinHeadroomMeasure')
            for b in cabin_headroom_list:
                cabin_headroom = b.childNodes[0].nodeValue
                stuff['cabin_headroom'] = cabin_headroom
            heads_list = node.getElementsByTagName('NumberOfHeadsNumeric')
            for b in heads_list:
                number_heads = b.childNodes[0].nodeValue
                stuff['number_heads'] = number_heads
            general_desc_list = 
node.getElementsByTagName('GeneralBoatDescription')
            for b in general_desc_list:
                general_description = b.childNodes[0].nodeValue
                stuff['general_description'] = general_description
            builder_list = node.getElementsByTagName('BuilderName')
            for b in builder_list:
                builder = b.childNodes[0].nodeValue
                stuff['builder'] = builder
            hull_list = node.getElementsByTagName('BoatHullMaterialCode')
            for b in hull_list:
                hull_construction = b.childNodes[0].nodeValue
                stuff['hull_construction'] = hull_construction
            max_speed_list = 
node.getElementsByTagName('MaximumSpeedMeasure')
            for b in max_speed_list:
                max_speed = b.childNodes[0].nodeValue
                stuff['max_speed'] = max_speed
            drive_type_list = node.getElementsByTagName('DriveTypeCode')
            for b in drive_type_list:
                drive_type = b.childNodes[0].nodeValue
                stuff['drive_type'] = drive_type
            tank_group = node.getElementsByTagName('Tank')
            for x in tank_group:
                tank1_use = node.getElementsByTagName('TankUsageCode')[:1]
                for b in tank1_use:
                    tank1_use = b.childNodes[0].nodeValue
                    stuff['tank1_use'] = tank1_use
                tank1_cap = 
node.getElementsByTagName('TankCapacityMeasure')[:1]
                for b in tank1_cap:
                    tank1_cap = b.childNodes[0].nodeValue
                    stuff['tank1_cap'] = tank1_cap
                tank1_num = 
node.getElementsByTagName('TankCountNumeric')[:1]
                for b in tank1_num:
                    tank1_count = b.childNodes[0].nodeValue
                    stuff['tank1_count'] = tank1_count
                tank2_use = node.getElementsByTagName('TankUsageCode')[:2]
                for b in tank2_use:
                    tank2_use = b.childNodes[0].nodeValue
                    stuff['tank2_use'] = tank2_use
                tank2_cap = 
node.getElementsByTagName('TankCapacityMeasure')[:2]
                for b in tank2_cap:
                    tank2_cap = b.childNodes[0].nodeValue
                    stuff['tank2_cap'] = tank2_cap
                tank2_num = 
node.getElementsByTagName('TankCountNumeric')[:2]
  
              for b in tank2_num:
                    tank2_count = b.childNodes[0].nodeValue
                    stuff['tank2_count'] = tank2_count
            accom_group = node.getElementsByTagName('Accommodation')
            for x in accom_group:
                acc1_use = 
node.getElementsByTagName('AcommodationTypeCode')[:1]
                for b in acc1_use:
                    acc1_use = b.childNodes[0].nodeValue
                    stuff['acc1_use'] = acc1_use
                acc1_num = 
node.getElementsByTagName('AccommodationCountNumeric')[:1]
                for b in acc1_num:
                    acc1_count = b.childNodes[0].nodeValue
                    stuff['acc1_count'] = acc1_count
                acc2_use = 
node.getElementsByTagName('AcommodationTypeCode')[:2]
                for b in acc2_use:
                    acc2_use = b.childNodes[0].nodeValue
                    stuff['acc2_use'] = acc1_use
                acc2_num = 
node.getElementsByTagName('AccommodationCountNumeric')[:2]
                for b in acc2_num:
                    acc2_count = b.childNodes[0].nodeValue
                    stuff['acc2_count'] = acc1_count
                acc3_use = 
node.getElementsByTagName('AcommodationTypeCode')[:3]
                for b in acc3_use:
                    acc3_use = b.childNodes[0].nodeValue
                    stuff['acc3_use'] = acc1_use
                acc3_num = 
node.getElementsByTagName('AccommodationCountNumeric')[:3]
                for b in acc3_num:
                    acc3_count = b.childNodes[0].nodeValue
                    stuff['acc3_count'] = acc1_count
            for node in 
getElementsByTagName('VehicleRemarketingEngineLineItem'):
                engine_group = 
node.getElementsByTagName('VehicleRemarketingEngine')
                for x in engine_group:
                    eng_list = node.getElementsByTagName('MakeString')
                    for b in eng_list:
                        eng_mfr = b.childNodes[0].nodeValue
                        stuff['eng_mfr'] = eng_mfr
                    eng_mod_list = node.getElementsByTagName('Model')
                    for b in eng_mod_list:
                        eng_model = b.childNodes[0].nodeValue
                        stuff['eng_model'] = eng_model
                    eng_type_list = 
node.getElementsByTagName('BoatEngineTypeCode')
                    for b in eng_type_list:
                        eng_type = b.childNodes[0].nodeValue
                    stuff['eng_type'] = eng_type
                    eng_fuel_list = 
node.getElementsByTagName('FuelTypeCode')
                    for b in eng_fuel_list:
                        eng_fuel = b.childNodes[0].nodeValue
                        stuff['eng_fuel'] = eng_fuel
                    eng_prop_list = 
node.getElementsByTagName('PropellerType')
                    for b in eng_prop_list:
                        propeller = b.childNodes[0].nodeValue
                        stuff['propeller'] = propeller
            status_list = node.getElementsByTagName('SaleStatus')
            for b in status_list:
                sale_status = b.childNodes[0].nodeValue
                stuff['sale_status'] = sale_status
        #raise NameError(eng_mfr)

    raise NameError(stuff)




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/u02CwQYjIHgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to