1.
long l_err
string ls_path,ls_filename,ls_filter
ls_filter="xml档案(*.xml),*.xml"
l_err=getfilesavename('请选择存储位置:',ls_path,ls_filename,'xml',ls_filter)
if fileexists(ls_path) then
if messagebox('提示','此文件已存在,是否覆盖?',stopsign!,yesno!,1)=2 then
return
end if
end if
dw_1.saveas(ls_path,xml!,true)
messagebox('提示','资料转档成功!')
2.
is_leve00 = Char(13)+Char(10)
is_leve01 = Char(13)+Char(10)+Space(4)
is_leve02 = Char(13)+Char(10)+Space(8)
is_leve03 = Char(13)+Char(10)+Space(12)
is_leve04 = Char(13)+Char(10)+Space(16)
is_leve05 = Char(13)+Char(10)+Space(20)
is_leve06 = Char(13)+Char(10)+Space(24)
is_leve07 = Char(13)+Char(10)+Space(28)
is_leve08 = Char(13)+Char(10)+Space(32) //初始化pbdom需要的变量
String ls_date,ls_filename,l_str,ls_path,ls_fullname,ls_err
Long lnum_sign
Boolean lb_sign
l_str = ''
pbdom_builder pbdom_build
pbdom_document pbdom_doc
pbdom_element pbdom_root
pbdom_processinginstruction pbdom_instr
pbdom_text pbdom_txt
Select to_char(sysdate,'yyyymmddhh24mi')
Into :ls_date
From dual;
ls_filename = ls_date+'.xml'
pbdom_build = Create pbdom_builder
pbdom_doc = Create pbdom_document
pbdom_instr = Create pbdom_processinginstruction
TRY
pbdom_doc = pbdom_build.buildfromstring(l_str)
pbdom_root = pbdom_doc.getrootelement()
pbdom_instr.setname('xml')
pbdom_instr.SetData('version="1.0" encoding="GB2312"')
f_hh(pbdom_root)//函数调用f_hh()
pbdom_txt = Create pbdom_text
pbdom_txt.setname('#text')
pbdom_txt.SetText(is_leve00)
pbdom_root.addcontent(Ref pbdom_txt)
Catch(pbdom_exception pbdom_ex)
MessageBox('提示','有异常信息:'+pbdom_ex.getmessage())
Destroy pbdom_build
Destroy pbdom_doc
Destroy pbdom_txt
Destroy pbdom_root
Destroy pbdom_instr
RETURN
END TRY;
ls_path = 'e:\mybad'
IF Not(directoryexists(ls_path)) THEN
createdirectory(ls_path)
END IF
IF FileExists(ls_path+'\'+ls_filename) THEN
IF MessageBox('提示','此文件已存在,是否覆盖?',stopsign!,yesno!,1) = 2 THEN
RETURN
END IF
END IF
lb_sign = pbdom_doc.SaveDocument(ls_path+'\'+ls_filename)
ls_fullname = 'e:/mygod/'+ls_filename
Destroy pbdom_build
Destroy pbdom_doc
Destroy pbdom_txt
Destroy pbdom_root
Destroy pbdom_instr
IF lb_sign = False THEN
MessageBox('提示','转档失败!')
Rollback Using sqlca;
RETURN
END IF
lnum_sign = xmlparsefile(ls_path+'\'+ls_filename,valnever!,ls_err)
IF lnum_sign < 0 THEN
MessageBox('提示','格式不正确!'+ls_err)
Rollback Using sqlca;
RETURN
END IF
Commit Using sqlca;
messagebox('提示','导出成功!')
1.
Long l_err,l_sign
String ls_path,ls_filename,ls_filter
ls_filter = "xml档案(*.xml),*.xml"
l_err = GetFileopenName('请选择导入文件:',ls_path,ls_filename,'xml',ls_filter)
l_sign = dw_1.ImportFile(xml!,ls_path)
IF l_sign < 0 THEN
MessageBox('提示','导入文件失败!')
RETURN
ELSE
MessageBox('提示','导入文件成功!')
RETURN
END IF
2.
using_objfirst u_obj
Long l_sign,l_row
String ls_path,ls_filename,ls_filter,bak_path,ls_err
bak_path='e:\mygod\bak'
ls_filter = "xml档案(*.xml),*.xml"
GetFileopenName('请选择导入文件:',ls_path,ls_filename,'xml',ls_filter)
//l_sign = dw_1.ImportFile(xml!,ls_path)
l_sign=xmlparsefile(ls_path,valnever!,ls_err)
if l_sign<0 then
messagebox('提示','您选择的档案结构有问题!')
return
end if
st_1.text='正在备份资料.....'
bak_path=bak_path+'\'+string(now(),'yyyymmdd')
if not directoryexists(bak_path) then
createdirectory(bak_path)
end if
filecopy(ls_path,bak_path+'\'+ls_filename,true)
st_1.text='正在接收资料.....'
if ls_path='' or isnull(ls_path) then return
u_obj=create using_objfirst
u_obj.of_process(ls_path,ls_filename)
l_row=dw_1.retrieve()
if row_count_l messagebox('提示','接收成功!')
st_1.text='接收资料成功.....'
return
end if
long l_max,i,ll_Rtn
string l_pbdom_type,l_obj_name
if as_fullname='' or isnull(as_fullname) then return
pbdom_builder pbdom_build
pbdom_element pbdom_root
pbdom_document pbdom_doc
pbdom_object pbdom_obj[]
pbdom_build= create pbdom_builder
pbdom_root=create pbdom_element
try
pbdom_doc=pbdom_build.buildfromfile(as_fullname)
pbdom_root=pbdom_doc.getrootelement()
pbdom_root.getcontent(pbdom_obj[])
l_max=upperbound(pbdom_obj[])
if l_max>0 then
for i=1 to l_max
l_pbdom_type=pbdom_obj[i].getobjectclassstring()
choose case lower(l_pbdom_type)
case 'pbdom_element'
l_obj_name=pbdom_obj[i].dynamic getname()
// messagebox('l_obj_name',l_obj_name)
choose case lower(l_obj_name)
case 'dw_area_row'
of_commit(pbdom_obj[i])
end choose
end choose
next
end if
catch(pbdom_exception pbdom_ex)
messagebox('提示','导入有异常:'+pbdom_ex.getmessage())
end try
FOR ll_Rtn = 1 TO UpperBound(pbdom_obj[])
DESTROY pbdom_obj[ll_Rtn]
NEXT
Long l_num,i,ll_Rtn
String l_type,l_obj_name
pbdom_object pbdom_array_obj[]
as_pbdom_obj.getcontent(pbdom_array_obj)
l_num = UpperBound(pbdom_array_obj)
FOR i = 1 To l_num
l_type = Lower(pbdom_array_obj[i].getobjectclassstring())
CHOOSE CASE l_type
CASE 'pbdom_element'
l_obj_name = pbdom_array_obj[i]. Dynamic GetName()
CHOOSE CASE Lower(l_obj_name)
CASE '地区编码'
tr_aa.area_no = pbdom_array_obj[i].Dynamic GetText()
CASE '地区名称'
tr_aa.area_nm = pbdom_array_obj[i].Dynamic GetText()
CASE '地区描述'
tr_aa.area_desc = pbdom_array_obj[i].Dynamic GetText()
CASE '地区层次'
tr_aa.area_leve = pbdom_array_obj[i].Dynamic GetText()
CASE '父地区编码'
tr_aa.parea_no = pbdom_array_obj[i].Dynamic GetText()
CASE '城市级别'
tr_aa.city_level = pbdom_array_obj[i].Dynamic GetText()
END CHOOSE
END CHOOSE
NEXT
of_update()
FOR ll_Rtn = 1 TO UpperBound(pbdom_array_obj[])
DESTROY pbdom_array_obj[ll_Rtn]
NEXT