Ok so I have realised that what I think I  need is a dict of dicts
so far I have a dict, stuff which will be populated by boat and engine
BUT it doesnt seem to work using
        for z in [boat, engine]:
            stuff.update(z)
to populate stuff but still seem to be getting a single boat result and no 
engine dict data 

    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'):
        boat = {}
        for node in x.getElementsByTagName('VehicleRemarketingBoat'):
            name_list = node.getElementsByTagName('MakeString')
            for n in name_list:
                name = n.childNodes[0].nodeValue
                boat['name'] =  name
            year_list = node.getElementsByTagName('ModelYear')
            for y in year_list:
                year = y.childNodes[0].nodeValue
                boat['year'] = year
            model_list = node.getElementsByTagName('Model')
            for m in model_list:
                model = m.childNodes[0].nodeValue
                boat['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
                    boat['length_code'] = length_code
                nlm = node.getElementsByTagName('BoatLengthMeasure')[:1]
                for lm in nlm:
                    nominal_length = lm.childNodes[0].nodeValue
                    boat['nominal_length'] = nominal_length
                loa_list = node.getElementsByTagName('BoatLengthCode')[:2]
                for loa in loa_list:
                    loa_code = loa.childNodes[0].nodeValue
                    boat['loa_code'] = loa_code
                loa_measure_list = 
node.getElementsByTagName('BoatLengthMeasure')[:2]
                for lm in loa_measure_list:
                    loa_measure = lm.childNodes[0].nodeValue
                    boat['loa_measure'] = loa_measure
                l_o_list = node.getElementsByTagName('BoatLengthCode')[:3]
                for loo in l_o_list:
                    length_overall_code = loo.childNodes[0].nodeValue
                    boat['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
                    boat['length_overall_measure'] = length_overall_measure
            bridge_list = 
node.getElementsByTagName('BridgeClearanceMeasure')
            for bl in bridge_list:
                bridge_clearance = bl.childNodes[0].nodeValue
                boat['bridge_clearance'] = bridge_clearance
            beam_list  = node.getElementsByTagName('BeamMeasure')
            for bm in beam_list:
                beam = bm.childNodes[0].nodeValue
                boat['beam'] = beam
            fuel_list  = 
node.getElementsByTagName('FuelTankCapacityMeasure')
            for f in fuel_list:
                fuel_capacity = f.childNodes[0].nodeValue
                boat['fuel_capacity'] = fuel_capacity
            hold_list  = 
node.getElementsByTagName('HoldingTankCapacityMeasure')
            for h in hold_list:
                hold_capacity = f.childNodes[0].nodeValue
                boat['hold_capacity'] = hold_capacity
            water_list  = 
node.getElementsByTagName('WaterTankCapacityMeasure')
            for w in water_list:
                water_capacity = w.childNodes[0].nodeValue
                boat['water_capacity'] = water_capacity
            cat_code_list  = node.getElementsByTagName('BoatCategoryCode')
            for c in cat_code_list:
                category_code = c.childNodes[0].nodeValue
                boat['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
                    boat['boat_class_code'] = boat_class_code
                pbci = 
node.getElementsByTagName('PrimaryBoatClassIndicator')[:1]
                for p in pbci:
                    primary_boat_class_indicator = p.childNodes[0].nodeValue
                    boat['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
                    boat['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
                    boat['secondary_boat_class_indicator'] = 
secondary_boat_class_indicator
            cruise_list = node.getElementsByTagName('CruisingSpeedMeasure')
            for cr in cruise_list:
                cruising_speed = cr.childNodes[0].nodeValue
                boat['cruising_speed'] = cruising_speed
            engine_list = 
node.getElementsByTagName('TotalEnginePowerQuantity')
            for e in engine_list:
                engine_power = e.childNodes[0].nodeValue
                boat['engine_power'] = engine_power
            berth_list = node.getElementsByTagName('NumberOfBerthsNumeric')
            for b in berth_list:
                number_berths = b.childNodes[0].nodeValue
                boat['number_berths'] = number_berths
            cabin_list = node.getElementsByTagName('NumberOfCabinsNumeric')
            for b in cabin_list:
                number_cabins = b.childNodes[0].nodeValue
                boat['number_cabins'] = number_cabins
            cabin_headroom_list = 
node.getElementsByTagName('CabinHeadroomMeasure')
            for b in cabin_headroom_list:
                cabin_headroom = b.childNodes[0].nodeValue
                boat['cabin_headroom'] = cabin_headroom
            heads_list = node.getElementsByTagName('NumberOfHeadsNumeric')
            for b in heads_list:
                number_heads = b.childNodes[0].nodeValue
                boat['number_heads'] = number_heads
            general_desc_list = 
node.getElementsByTagName('GeneralBoatDescription')
            for b in general_desc_list:
                general_description = b.childNodes[0].nodeValue
                boat['general_description'] = general_description
            builder_list = node.getElementsByTagName('BuilderName')
            for b in builder_list:
                builder = b.childNodes[0].nodeValue
                boat['builder'] = builder
            hull_list = node.getElementsByTagName('BoatHullMaterialCode')
            for b in hull_list:
                hull_construction = b.childNodes[0].nodeValue
                boat['hull_construction'] = hull_construction
            max_speed_list = 
node.getElementsByTagName('MaximumSpeedMeasure')
            for b in max_speed_list:
                max_speed = b.childNodes[0].nodeValue
                boat['max_speed'] = max_speed
            drive_type_list = node.getElementsByTagName('DriveTypeCode')
            for b in drive_type_list:
                drive_type = b.childNodes[0].nodeValue
                boat['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
                    boat['tank1_use'] = tank1_use
                tank1_cap = 
node.getElementsByTagName('TankCapacityMeasure')[:1]
                for b in tank1_cap:
                    tank1_cap = b.childNodes[0].nodeValue
                    boat['tank1_cap'] = tank1_cap
                tank1_num = 
node.getElementsByTagName('TankCountNumeric')[:1]
                for b in tank1_num:
                    tank1_count = b.childNodes[0].nodeValue
                    boat['tank1_count'] = tank1_count
                tank2_use = node.getElementsByTagName('TankUsageCode')[:2]
                for b in tank2_use:
                    tank2_use = b.childNodes[0].nodeValue
                    boat['tank2_use'] = tank2_use
                tank2_cap = 
node.getElementsByTagName('TankCapacityMeasure')[:2]
                for b in tank2_cap:
                    tank2_cap = b.childNodes[0].nodeValue
                    boat['tank2_cap'] = tank2_cap
                tank2_num = 
node.getElementsByTagName('TankCountNumeric')[:2]
                for b in tank2_num:
                    tank2_count = b.childNodes[0].nodeValue
                    boat['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
                    boat['acc1_use'] = acc1_use
                acc1_num = 
node.getElementsByTagName('AccommodationCountNumeric')[:1]
                for b in acc1_num:
                    acc1_count = b.childNodes[0].nodeValue
                    boat['acc1_count'] = acc1_count
                acc2_use = 
node.getElementsByTagName('AcommodationTypeCode')[:2]
                for b in acc2_use:
                    acc2_use = b.childNodes[0].nodeValue
                    boat['acc2_use'] = acc1_use
                acc2_num = 
node.getElementsByTagName('AccommodationCountNumeric')[:2]
                for b in acc2_num:
                    acc2_count = b.childNodes[0].nodeValue
                    boat['acc2_count'] = acc1_count
                acc3_use = 
node.getElementsByTagName('AcommodationTypeCode')[:3]
                for b in acc3_use:
                    acc3_use = b.childNodes[0].nodeValue
                    boat['acc3_use'] = acc1_use
                acc3_num = 
node.getElementsByTagName('AccommodationCountNumeric')[:3]
                for b in acc3_num:
                    acc3_count = b.childNodes[0].nodeValue
                    boat['acc3_count'] = acc1_count
            status_list = node.getElementsByTagName('SaleStatus')
            for b in status_list:
                sale_status = b.childNodes[0].nodeValue
                boat['sale_status'] = sale_status
        engine = {}
        for node in 
x.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
                    engine['eng_mfr'] = eng_mfr
                eng_mod_list = node.getElementsByTagName('Model')
                for b in eng_mod_list:
                    eng_model = b.childNodes[0].nodeValue
                    engine['eng_model'] = eng_model
                eng_type_list = 
node.getElementsByTagName('BoatEngineTypeCode')
                for b in eng_type_list:
                    eng_type = b.childNodes[0].nodeValue
                    engine['eng_type'] = eng_type
                eng_fuel_list = node.getElementsByTagName('FuelTypeCode')
                for b in eng_fuel_list:
                    eng_fuel = b.childNodes[0].nodeValue
                    engine['eng_fuel'] = eng_fuel
                eng_prop_list = node.getElementsByTagName('PropellerType')
                for b in eng_prop_list:
                    propeller = b.childNodes[0].nodeValue
                    engine['propeller'] = propeller
        for z in [boat, engine]:
            stuff.update(z)
    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/-/laLu5FvsQZ0J.
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