最近临时工作要生成xml报名,通过MQ接口发送。简单小程序。
自增长拼成xml报文
Test_001.py
# encoding=utf-8
import time
orderId = ''
s1= "\n"
#
for ID in range(1,5):
item1 = "<item>" + \
"<orderID>" + str(ID) + "</orderID>" + \
"<time>" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + "</time>" + \
"</item>"
orderId+=item1
messge = "<MbfBody>" + orderId + "</MbfBody> "
print(messge)
另外一种状态
#encoding=utf-8
# str=input("输入字段:")
str='lxs,hqq,lj,xc'
List=str.split(',')
# str_xml=input("输入替换的模板:")
str_xml='<step id="xml_set_xml_value" comment="value" isrun="true"><param id="xml">VAR_XML</param><param id="xpath">//MbfBody/value</param><param id="value">COLUMN(VALUE,y)</param></step>'
#列表追加,回车成多行
def add_xml(L):
xml_l