Your code works absolutely fine with the w3schools link.
But for my .xml, I can read just the first line with the below error:
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, 'xml')
<?xml version="1.0" encoding="utf-8"?>
Few points:
1. What is a markup? How do we open this and resolve the error?
2. Am I not pointing to the root element? When I compare the 'w3schools.xml' with my xml, there is change in the first line. My xml header is extended (<?xml version='1.0' encoding='UTF-8'?><IM415 xmlns="http://www.ros.ie/schemas/customs/IM415">) See below.
Here's my code:
<?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>NIK243104_16nUlp</LRN_2_5>
<ValuationInformation>
<InvoiceCurrency_4_10>AFA</InvoiceCurrency_4_10>
<InvoiceAmount_4_11>5000</InvoiceAmount_4_11>
<InternalCurrency_4_12>AFA</InternalCurrency_4_12>
</ValuationInformation>
<GoodsInformation>
<GrossMass_6_5>33300</GrossMass_6_5>
<TotalPackageNumber_6_18>1665</TotalPackageNumber_6_18>
</GoodsInformation>
I'm expecting the below to be printed and copied to my test.xml:
<?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>NIK243104_16nUlp</LRN_2_5>
<ValuationInformation>
<InvoiceCurrency_4_10>AFA</InvoiceCurrency_4_10>
<InvoiceAmount_4_11>5000</InvoiceAmount_4_11>
<InternalCurrency_4_12>AFA</InternalCurrency_4_12>
</ValuationInformation>
<GoodsInformation>
<GrossMass_6_5>33300</GrossMass_6_5>
<TotalPackageNumber_6_18>1665</TotalPackageNumber_6_18>
</GoodsInformation>
<GrossMass_6_5>33300</GrossMass_6_5>
<TotalPackageNumber_6_18>1665</TotalPackageNumber_6_18>
</GoodsInformation>
But for my .xml, I can read just the first line with the below error:
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, 'xml')
<?xml version="1.0" encoding="utf-8"?>
Few points:
1. What is a markup? How do we open this and resolve the error?
2. Am I not pointing to the root element? When I compare the 'w3schools.xml' with my xml, there is change in the first line. My xml header is extended (<?xml version='1.0' encoding='UTF-8'?><IM415 xmlns="http://www.ros.ie/schemas/customs/IM415">) See below.
Here's my code:
response = requests.get(driver.current_url) soup = BeautifulSoup(response.content, 'xml') print(soup) # Save to disk with open('test.xml', 'w') as fp: fp.write(soup.prettify())My Xml looks like below:
<?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>NIK243104_16nUlp</LRN_2_5>
<ValuationInformation>
<InvoiceCurrency_4_10>AFA</InvoiceCurrency_4_10>
<InvoiceAmount_4_11>5000</InvoiceAmount_4_11>
<InternalCurrency_4_12>AFA</InternalCurrency_4_12>
</ValuationInformation>
<GoodsInformation>
<GrossMass_6_5>33300</GrossMass_6_5>
<TotalPackageNumber_6_18>1665</TotalPackageNumber_6_18>
</GoodsInformation>
I'm expecting the below to be printed and copied to my test.xml:
<?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>NIK243104_16nUlp</LRN_2_5>
<ValuationInformation>
<InvoiceCurrency_4_10>AFA</InvoiceCurrency_4_10>
<InvoiceAmount_4_11>5000</InvoiceAmount_4_11>
<InternalCurrency_4_12>AFA</InternalCurrency_4_12>
</ValuationInformation>
<GoodsInformation>
<GrossMass_6_5>33300</GrossMass_6_5>
<TotalPackageNumber_6_18>1665</TotalPackageNumber_6_18>
</GoodsInformation>
<GrossMass_6_5>33300</GrossMass_6_5>
<TotalPackageNumber_6_18>1665</TotalPackageNumber_6_18>
</GoodsInformation>
(Mar-21-2024, 10:13 PM)snippsat Wrote:(Mar-21-2024, 06:27 PM)Nik1811 Wrote: I get ''https://www.********/aep2/xml/sad/NIK243179-AI.xml as my generated xmlPost your code,from what are you generated this .xml?
Then need just to save the content of .xml,and not use url as in my demos.
If you run my code(no changes) dos that work?