xml转成特定格式

xml文件 --xml_bw.txt

1不错
2

22

目标格式

king:://king::xpath/jpath::RESPONSE
new:://new::xpath/jpath::RESPONSE
tests:://tests::xpath/jpath::RESPONSE

Python脚本实现:

import re


def xml_dict(xml_file):
        f=open(xml_file,'rb')
        #xml的内容转成str
        s =f.read().decode('utf-8')
        # 提取value
        a =re.findall(r'[>](.*?)[<]',s)
        # 提取key
        b =re.findall(r'[<](.*?)[>]',s)
        # print(b)

        dict={} #创建空dict存值
        i=j=0
        while i

你可能感兴趣的:(xml转成特定格式)