Mar-22-2024, 01:37 PM
I'm trying to read the below xml generated in a browser using Beautifulsoup:
<?xml version='1.0' encoding='UTF-8'?><IM415 xmlns="http://www.ros.ie/schemas/customs/IM415">
<Declaration>
<MsgType>H1</MsgType>
<DeclarationType_1_1>IM</DeclarationType_1_1>
<AdditionalDeclarationType_1_2>A</AdditionalDeclarationType_1_2>
<LRN_2_5>NIK243186_16KAkj</LRN_2_5>
<ValuationInformation>
<InvoiceCurrency_4_10>EUR</InvoiceCurrency_4_10>
<InvoiceAmount_4_11>5000</InvoiceAmount_4_11>
<InternalCurrency_4_12>EUR</InternalCurrency_4_12>
</ValuationInformation>
<GoodsInformation>
<GrossMass_6_5>300</GrossMass_6_5>
<TotalPackageNumber_6_18>15</TotalPackageNumber_6_18>
</GoodsInformation>
My code is below:
MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
soup = BeautifulSoup(response.content, 'lxml-xml')
<?xml version="1.0" encoding="utf-8"?>
Please help to convert the browser generated xml to be read by BeautifulSoup and get rid of the Markup error.
<?xml version='1.0' encoding='UTF-8'?><IM415 xmlns="http://www.ros.ie/schemas/customs/IM415">
<Declaration>
<MsgType>H1</MsgType>
<DeclarationType_1_1>IM</DeclarationType_1_1>
<AdditionalDeclarationType_1_2>A</AdditionalDeclarationType_1_2>
<LRN_2_5>NIK243186_16KAkj</LRN_2_5>
<ValuationInformation>
<InvoiceCurrency_4_10>EUR</InvoiceCurrency_4_10>
<InvoiceAmount_4_11>5000</InvoiceAmount_4_11>
<InternalCurrency_4_12>EUR</InternalCurrency_4_12>
</ValuationInformation>
<GoodsInformation>
<GrossMass_6_5>300</GrossMass_6_5>
<TotalPackageNumber_6_18>15</TotalPackageNumber_6_18>
</GoodsInformation>
My code is below:
response = requests.get(driver.current_url) print(response) soup = BeautifulSoup(response.content, 'lxml-xml') print(soup) # Save to disk with open('test.xml', 'w') as fp: fp.write(soup.prettify())Error as below:
MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
soup = BeautifulSoup(response.content, 'lxml-xml')
<?xml version="1.0" encoding="utf-8"?>
Please help to convert the browser generated xml to be read by BeautifulSoup and get rid of the Markup error.