我希望从xml标记获取数据到脚本文件,但数据是十六进制字符行(&
>
),需要转换为表格(&&>) 。
示例:
<project>
<code><shell> if a && b </shell></code>
</project>
我可以使用命令
提取标签xmlstarlet edit --update 'project/code/shell' --value "$DATA" shell.xml > shell.sh
cat shell.sh
实际值:
if a && b
预期:
if a && b
如何实现预期结果?
答案 0 :(得分:1)
要取消特殊的XML字符:
if a && b
输出:
cat file.xml | xmlstarlet unescape
<project>
<code><shell> if a && b </shell></code>
</project>
输出:
def save_report(request):
if request.method == 'POST':
print(request.POST.dict())
data_dict = request.POST.dict()
query_json = {}
#query json data
query_json['data_src_name'] = data_dict['data_src_name']
query_json['fields'] = data_dict['fields']
query_json['group_by'] = data_dict['group_by']
query_json['order_by'] = data_dict['order_by']
query_json['where'] = data_dict['where']
query_json['limit'] = data_dict['limit']
query_json = json.dumps(query_json)
report_creation_obj = ReportCreationData.objects.create(
query_json = query_json,
data_source_name = data_dict['data_src_name'],
query_name = data_dict['query_name'],
mail_body = data_dict['mail_body'])
report_creation_obj.save()
return HttpResponse('success')
else:
return render(request, 'home/report_creation.html', context = None)
database :
query_name = models.CharField(max_length=100,unique= True, default= True)