我是一个pythonnoob,试图使用Elementtree解析xmlapi响应。响应包含来自窗体的自定义数据,我在尝试访问某些嵌套元素时遇到问题。以下是我的代码:
response = requests.get("https://crm.zoho.com/crm/private/xml/Deals/getCVRecords?newFormat=1&authtoken=authtoken&scope=crmapi&cvName=Open Deals")
tree = ElementTree.fromstring(response.content)
print (response.text)
通过这个电话,我可以得到以下回复:
^{pr2}$我试图访问DEALID(123456789)以及[CDATA[HELPME]]元素中的HELPME。非常感谢任何帮助。谢谢!在
我强烈建议你去看看https://github.com/martinblech/xmltodict。我已经将它用于大量的XML处理,它非常可靠。在
下面的代码应该找到并打印出找到的每个交易id。在
deal_id_elem = row.find('FL[@val="DEALID"]')
查找属性val
等于DEALID
的元素。这是 Xpath syntax相关问题 更多 >
编程相关推荐