我使用BeautifulSoup在網頁上提交表單。該頁面返回類似於下面的一個textarea的XML結果:如何使用python解析textarea中的Xml並返回json?
<textarea name='xmlresults' rows='40' cols='150'>
<?xml version="1.0" encoding="UTF-8"?>
<companies>
<company name=」Acme Corp」 timestamp="2012-09-04 02:49:39">
<officers>
<officer name=」John Doe」 position=」CEO」 />
</officers>
</company>
</companies>
</textarea>
我想使用Python來解析結果,並返回一個JSON結果。我正在尋找一些關於處理這個問題的最佳方法的指導。
到目前爲止您嘗試過什麼?什麼失敗了?我們可以幫助您解決具體問題,但您似乎在要求我們爲您編寫代碼。 –