A really big challenge (for me at least) - XML File Import into DB

P

PaulHilgeman

Hello,

I have a database with 2 main tables, an ORDERS table, that contains
all of the details about an order, name, address etc. There is
obviously an OrderID field.

THe second table is "ORDER DETAILS" containing all of the line items
for each job. I believe that this is a very typical set-up.

A company that we contract with sends us XML files containing all of
the days new orders. I need to get the data out of the single large
XML file and into the two tables.

I am wondering if there is an easy way to do this. I mean I could do
somthing crude with a MS Word macro or somthing just to shuffle the
text around into the apopriate colums etc, but there has to be a better
way.

Below is a copy of a section of the XML file. I have surrounded items
with #### that need to go into the ORDERS table and surrounded them
with @@@@ if they need to go into the "ORDER DETAILS" table. Keep in
mind that this is one in a list of 200-300 per day, and the only way
that it is available is a single file. Also, you will notice that
there are 3 line items in this example. There could be anywhere
between 0 and 15 or so of these line items.

Any suggestions would be very helpful, if I dont get any I am just
going to have to write a macro in a text editor to shuffle the text
around and then import by hand into Access.

Thanks a ton!!!


***********************The XML File***************************

<hd:ixnet_instl_updt_list_entry>
<hd:instl_dtl_vw1
str_nbr="####STORE NUMBER####"
cust_ord_nbr="0000189896"
svc_line_nbr="00009"
cust_ord_stat_cd="00800"
d_cust_ord_stat_cd="SoldBalDue"
s_cord_stat_desc="Sold. Balance due"
cust_ord_stat_desc="Sold. Balance due"
fllw_up_actn_txt="Schedule Service"
mvndr_nbr="0050073691"
instl_line_nbr="00009"
po_nbr="####PURCHASE ORDER NUMBER####"
svc_typ_cd="I"
svc_stat_cd="00327"
d_svc_stat_cd="Inst Req M"
s_svc_stat_desc="Install requested-M"
svc_stat_desc="Install requested manually"
sku_nbr="0000255540"
shrt_sku_desc="####JOB DESCRIPTION####"
sku_desc=""
ord_cost_amt="####TOTAL JOB PAY####"
ord_retl_amt="'00000000000000.0000"
est_instl_bgn_dt=" "
est_instl_end_dt=" "
curr_instl_bgn_dt=" "
curr_instl_end_dt=" "
cmplt_vrfy_dt=" "
cmplt_user_aud_id=" "
job_prmt_nbr=" "
svc_site_nbr="00009"
addr_line1_txt="####ADDRESS LINE 1####"
addr_line2_txt=" "
city_nm="####CITY####"
st_cd="####STATE####"
pstl_cd="####ZIP####"
fllw_up_dt="2006-01-22"
rewrk_typ_ind="2"
rel_cust_ord_nbr=" "
rel_instl_nbr="00001"
addl_trip_retl_amt="'00000000000000.0000"
trip_cost_mult_ftr="'099.90"
uoi_cd="00270"
d_uoi_cd="SY"
s_uoi_desc="SQUARE YARD"
uoi_desc="SQUARE YARD"
instl_retl_amt="'00000000000005.7600"
instl_cost_amt="@@@@LINE ITEM 1 PAY@@@@"
instl_qty="@@@@LINE ITEM 1 QTY@@@"
prc_list_opt_nbr="00001"
prc_list_opt_desc="@@@@LINE ITEM 1 DESCRIPTION@@@@"
spl_instr_txt="####NOTES####"
stat_eff_ts="2006-01-17-17.52.46.516000"
svc_site_cntct_nm="####CONTACT NAME####"
cntry_cd="US"
phn_area_city_cd="####AREA CODE 1####"
phn_locl_nbr="####PHONE 1####"
phn_ext_nbr=" "
alt_phn_acty_cd="####AREA CODE 2####"
alt_phn_locl_nbr="####PHONE 2####"
alt_phn_ext_nbr=" "
bpr_phn_acty_cd=" "
bpr_phn_locl_nbr=" "
bpr_phn_ext_nbr=" "
act_bgn_dt=" "
prev_purch_mer_flg="N"
mer_dept_nbr="00023"/>
<hd:hcust_dtl_vw1>
<hd:n_str_svc_hcust_vw1
str_svc_hcust_nbr="0057651517"
cust_typ_cd="00001"
cust_stat_cd="00001"
cust_stat_eff_dt=" "
cntct_meth_cd="00000"
cust_addr_typ_cd="00000"
phn_nbr_typ_cd="00000"
email_addr_typ_cd="00000"
cntct_wk_bgn_tm=" "
cntct_wk_end_tm=" "
cntct_wknd_bgn_tm=" "
cntct_wknd_end_tm=" "
last_upd_user_id="rental"
last_upd_ts="2005-10-10-17.13.21.000000"/>

<hd:str_svc_indv_hcust
str_svc_hcust_nbr="0057651517"
frst_nm="####FIRST NAME####"
mid_nm=" "
last_nm="####LAST NAME####"
sfx_nm=" "
ttl_nm=" "
brth_dt=""
last_upd_user_id="rental"
last_upd_ts="2005-10-10-17.13.21.000000"/>

<hd:str_svc_hcust_phn_typ_vw1_list>
<hd:str_svc_hcust_phn_typ_vw1_list_entry
str_svc_hcust_nbr="0057651517"
phn_nbr_typ_cd="00001"
phn_area_city_cd="314"
phn_locl_nbr="8631860"
phn_ext_nbr=" "
cntry_cd="US"
pref_phn_flg=" "
phn_pin_nbr=" "
last_upd_user_id="rental"
last_upd_ts="2005-10-10-17.13.21.000000"
d_phn_nbr_typ_cd="1"
s_phn_nbr_typ_desc="PRIMARY"
phn_nbr_typ_desc="PRIMARY"
abbr_cntry_nm="US"
s_cntry_nm="UNITED STATES"
cntry_nm="UNITED STATES"
sel_flg="0"/>

<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:str_svc_hcust_phn_typ_vw1_list>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:hcust_dtl_vw1>
<hd:epr_bu_vw1_list_entry
bu_id="7444984421187368750001MV"
bu_typ_cd="00009"
org_bu_id="1"
lob_cd="00001"
tm_rgn_id="00004"
base_curnc_typ_cd="USD"
eff_bgn_dt="1996-08-09"
eff_end_dt="9999-12-31"
cmmn_bu_nm="3002"
lang_cd="en_US"
abbr_bu_nm="HRD"
s_bu_nm="HANLEY RD"
bu_nm="HANLEY RD & 40">
<hd:epr_bu_addr_vw1_list>

<hd:epr_bu_addr_vw1_list_entry
addr_id="7444984421187368750002MV"
addr_role_cd="00002"
addr_line1_txt="1603 S HANLEY RD"
addr_line2_txt=" "
addr_line3_txt=" "
addr_line4_txt=" "
addr_line5_txt=" "
city_nm="BRENTWOOD"
st_cd="MO"
pstl_cd="63144"
cnty_nm="SAINT LOUIS"
cntry_cd="US"/>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:epr_bu_addr_vw1_list>
<hd:epr_bu_telco_vw1_list>

<hd:epr_bu_telco_vw1_list_entry
telco_id="7444984421187368750003MV"
phn_area_city_cd="314"
phn_locl_nbr="6476050"
phn_ext_nbr=" "
phn_pin_nbr=" "
cntry_cd="US"
cmech_role_cd="00001"
d_cmech_role_cd="WORK"
s_cmech_role_desc="Bus/Work"
cmech_role_desc="Business or Work"
cntct_meth_cd="00001"
dspl_cntct_meth_cd="PHN"
s_cntct_meth_desc="Phone"
cntct_meth_desc="Regular Telephone"/>

<hd:epr_bu_telco_vw1_list_entry
telco_id="7444984421187368750004MV"
phn_area_city_cd="314"
phn_locl_nbr="9511316"
phn_ext_nbr=" "
phn_pin_nbr=" "
cntry_cd="US"
cmech_role_cd="00001"
d_cmech_role_cd="WORK"
s_cmech_role_desc="Bus/Work"
cmech_role_desc="Business or Work"
cntct_meth_cd="00004"
dspl_cntct_meth_cd="FAX"
s_cntct_meth_desc="Fax"
cntct_meth_desc="Facsimile / Fax Machine"/>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:epr_bu_telco_vw1_list>
<hd:epr_bu_assoc_vw1_list>
<hd:epr_bu_assoc_vw1_list_entry
prsn_id="7447861077458311790004MV"
frst_nm=""
mid_nm="M"
last_nm=""
sfx_nm=" "
ttl_nm="Mr"
pref_lang_cd="en_US"
pref_nm=" "
sysusr_id="7447861077459311790001MV"
actv_flg="Y"
assg_bu_id="7444984421187368750001MV"
email_addr_txt=" "
user_id="SME889"
dept_nbr="00003"
abbr_dept_nm=" STORE MGR"
shrt_dept_nm=" STORE MGRS"
dept_nm=" STORE MGRS"
curr_hire_dt="1994-01-24"
last_wrk_dt=" "
jdsgntn_cd="00611"
job_ttl_cd="STRMGR"
dspl_ttl_cd="STRMGR"
s_job_ttl_desc=" "
job_ttl_desc="STORE MANAGER"
empl_id="317907659"/>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:epr_bu_assoc_vw1_list>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:epr_bu_vw1_list_entry>
<hd:n_opt_instl_vw1_list>
<hd:n_opt_instl_vw1_list_entry
cust_ord_nbr="0000189896"
instl_line_nbr="00009"
opt_instl_item_nbr="00002"
str_nbr="3002"
uoi_cd="00270"
d_uoi_cd="SY"
s_uoi_desc="SQUARE YARD"
uoi_desc="SQUARE YARD"
ord_qty="@@@@LINE ITEM 2 QUANTITY@@@@"
ord_cost_amt="@@@@LINE ITEM 2 PAY@@@@"
ord_retl_amt="'00000000000001.6200"
prc_list_opt_nbr=" "
prc_list_opt_desc=" "
instl_desc="@@@@LINE ITEM 2 DESCRIPTION@@@@"
sel_flg="0"/>
<hd:n_opt_instl_vw1_list_entry
cust_ord_nbr="0000189896"
instl_line_nbr="00009"
opt_instl_item_nbr="00003"
str_nbr="3002"
uoi_cd="00270"
d_uoi_cd="SY"
s_uoi_desc="SQUARE YARD"
uoi_desc="SQUARE YARD"
ord_qty="'@@@@LINE ITEM 3 QUANTITY@@@@"
ord_cost_amt="'@@@@LINE ITEM 3 PAY@@@@"
ord_retl_amt="'00000000000001.8000"
prc_list_opt_nbr=" "
prc_list_opt_desc=" "
instl_desc="@@@@LINE ITEM 3 DESCRIPTION@@@@"
sel_flg="0"/>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:n_opt_instl_vw1_list>
<hd:cstm_instl_vw1_list>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:cstm_instl_vw1_list>
<hd:n_so_mer_vw2_list>
<hd:n_so_mer_vw2_list_entry
cust_ord_nbr="0000189896"
str_nbr="3002"
so_line_nbr="00008"
so_mer_line_nbr="00001"
sku_nbr="0000369333"
shrt_mer_desc="B/FR, REC RO, BSMT STAIRS"
mer_desc="COLOR: 35512 ARMOIRE 12' X 70' 6'
35512 ARMOIRE"
mvndr_part_nbr="FINEST HOUR"
ord_qty="'000000000094.000000"
mer_qty="0"
rel_will_call_nbr=" "
rel_dlvry_nbr=" "
uoi_cd="00270"
d_uoi_cd="SY"
s_uoi_desc="SQUARE YARD"
po_nbr="02568366"
expctd_arvl_dt="2006-01-24"
mvndr_nbr="0060623033"
bu_id="7446348513901325740001MV"
bu_nm="S/O ROYALTY CARPETS"
abbr_bu_nm="S/O ROYALT"
s_bu_nm="S/O ROYALTY CARPETS"
evnt_ts="0001-01-01-00.00.00.000000"
svc_typ_cd="S"
dlvry_loc_ind="I"
will_call_typ_ind=" "
sel_flg="0"/>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:n_so_mer_vw2_list>
<hd:n_reg_mer_vw2_list>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:n_reg_mer_vw2_list>
<hd:stat msg_nbr="00000"
struct_id=" "
attr_id=" "/>
</hd:ixnet_instl_updt_list_entry>
 
P

PaulHilgeman

Hmmmm.... I dont think so, I have a well-developed application here in
access, plus, I need to do 60-70 thousand entries a year, I need the
robustness of access.

-Paul
 
Top