有什么方法可以从 python HttpResponse 获取 xml 数据(通过 Javascript)并将其放入网页上的 body 元素中?
python中有我的xml示例:
import xml.etree.ElementTree as ET
root = ET.Element("table")
tr = ET.SubElement(root, "tr")
td = ET.SubElement(tr, "td")
td.text = "some text"
tree = ET.ElementTree(root)
response = HttpResponse(tree)
JS:
$(document).ready(function() {
$.get("http://localhost:8000/getXml", function(data){
alert(data);
});
});
感谢帮助。