|
我也贴一个,读取xml文件并更新若干结点信息后保存到另一文件!
#¶ÁÈ¡xml1302Îļþ£¬²¢½«ÏàÓ¦ÐÅÏ¢¸üÐÂ
public function file1302read(in filepath,in mysoid,in mysid)
{
#´ò¿ª1302Îļþ
auto filename = filepath & "1302.xml";
auto filename1;
auto xml[];
auto i = 0;
auto j = 0;
auto line;
auto xyuan;
auto pos;
auto res = file_open(filename,0);
if(res != E_OK)
{
printf("file 1302 open error!");
}
#´ÓÎļþÖжÁ³öÄÚÈݲ¢Ð´ÈëÊý×é
while(file_getline(filename,line) == 0)
{
xml[i] = line;
i++;
}
file_close(filename);
#¸üÐÂRequestID
for(j = 0; j < i; j++)
{
xyuan = xml[j];
if( index(xyuan,"<RequestId>") > 0 )
{
pos = index(xyuan,"<RequestId>");
xyuan = substr(xyuan,1,pos+10) & "front_" & get_time() & "</RequestId>";
xml[j] = xyuan;
break;
}
}
#¸üÐÂServiceOrderID
for(j = 0; j < i; j++)
{
xyuan = xml[j];
if( index(xyuan,"<ServiceOrderId>") > 0 )
{
pos = index(xyuan,"<ServiceOrderId>");
xyuan = substr(xyuan,1,pos+15) & mysoid & "</ServiceOrderId>";
xml[j] = xyuan;
break;
}
}
#¸üÐÂServiceID
for(j = 0; j < i; j++)
{
xyuan = xml[j];
if( index(xyuan,"<ServiceId>") > 0 )
{
pos = index(xyuan,"<ServiceId>");
xyuan = substr(xyuan,1,pos+10) & mysid & "</ServiceId>";
xml[j] = xyuan;
break;
}
}
#´ò¿ªÎļþ²¢Ð´ÈëÒѸüеÄÄÚÈÝ
filename1 = filepath & "13021.xml";
res = file_open(filename1,1);
if(res != E_OK)
{
tl_step("file 1302 write open",1,"file open error!");
}
for(j = 0; j < i; j++)
{
file_printf(filename1,xml[j],j+1);
}
file_close(filename1);
} |
|