我有以下来自某个服务的名字空间
<soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:soap=http://www.4cgroup.co.za/soapauth xmlns:gen=http://www.4cgroup.co.za/genericsoap>
尝试解析此请求时,我收到以下错误
xml.etree.ElementTree.ParseError: not well-formed
我注意到命名空间值上没有""
。如何用正则表达式添加它们
正确的格式
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://www.4cgroup.co.za/soapauth" xmlns:gen="http://www.4cgroup.co.za/genericsoap">
注意双引号
使用正则表达式:
输出:
注意正则表达式并不完美。它适用于这种情况,但如果URL变得更“独特”,它可能会失败
记入this answer
这个正则表达式似乎做到了:
输出:
在线查看here
相关问题 更多 >
编程相关推荐