Search code examples
pythonxmlescapingentity

ERROR: The reference to entity "format" must end with the \';\' delimiter.'


Quick one here. I'm getting the following XML parse error:

'ShortMessage': 'XML Parse error.', 'LongMessage': 'XML Error Text: "; nested exception is: \n\torg.xml.sax.SAXParseException: The reference to entity "format" must end with the \';\' delimiter.".', 'ErrorCode': '5', 'SeverityCode': 'Error', 'ErrorParameters': {'Value': '; nested exception is: \n\torg.xml.sax.SAXParseException: The reference to entity "format" must end with the \';\' delimiter.', '_ParamID': '0'}, 'ErrorClassification': 'RequestError'}

Obviously I need to escape something in my XML string but I cannot find what the entity "format" refers to.

Any ideas?

The full XML string is here:

ebaysdk [DEBUG]:body=b'<?xml version=\'1.0\' encoding=\'utf-8\'?><VerifyAddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"><RequesterCredentials><eBayAuthToken>AgAAAA**AQAAAA**aAAAAA**UVVjWw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wAkoWkCJKAogydj6x9nY+seQ**CIcEAA**AAMAAA**FDD2WJhYQevQg3n2JdAi1QmKWYDq+2t1kLtSqTkKUKvPmC8hTJ7lMtxV6/2GxTTFrn5QfsJU2MQfhechdJvGmlN4KvRzLEXc110hL9acOCXDJX108DuDKqV7GvOl/wP0xRRqTFNeTso3bfXNLHVBDKC+TKGZDLiyjgBQb4NJXSJ8/MGTrP+T21VAwhj0wHtS01cqLZjQkFWPyYJZLKxSNVPMSRkMdMBjSlPbtUtYGrPGGAUi1L5/vWL2ZMbnRMRd9O4oIsCYFLqARrL0V1jwrPFfmS2Bj+UivgRbnnsojnY80QwdQndUEgkOrWrav7HiI/Uw2B0hv/0ae86BMzivLOV4B9AOqtnHsiGwW1T6QdK3jjytBWtbyIf+ONUCf+UHH8j2qzo+aRS4wb/8xz/LWVNXYPwFYxmqCoWBIoAhmpBl3Vsa7hi13R6tYDsjlWRstpktQkEheWVBdQL767DXZZkrBqEM2Qv/JavMBy5zZqqA+a4KG/TacW/8v1TP7VV8iODPOahU6AxR3EkHxZwfLByur50kcpRnMzbHMb5XLXym+RaqW0RUQZGTB4uYahXaotMoUbFRmKBWqAG9/hOEzd2fkNK2UNg064+FIcqf4SdJh1+hAMdGCQdNHEs/uTg89hPQjDSGlpo2RghJx2zYQN4V5KuS/X/z9J2zmH5qqcu57G9IZi+6FYi8gk2Jr3tONc6vERL/zcMPSzmsone5jfJgfkR+2MjSwmH4gg7WcSrQHWtVNYU5U6ZkvmFPDg7g</eBayAuthToken></RequesterCredentials><Item><BestOfferDetails><BestOfferEnabled>false</BestOfferEnabled></BestOfferDetails><CategoryMappingAllowed>true</CategoryMappingAllowed><ConditionID>3000</ConditionID><Country>GB</Country><Currency>GBP</Currency><Description> Watches - Suunto Core - Grey Crush This mountain focused watch has a host of features that help you navigate, monitor your ascent or descent and predict weather changes in the hills.  The Core combines altimeter, barometer and a compass with weather information,as well as the essential features for adventures outdoors. </Description><DispatchTimeMax>1</DispatchTimeMax><ItemSpecifics><NameValueList><Name>Brand</Name><Value>Suunto</Value></NameValueList><NameValueList><Name>MPN</Name><Value>SS020691000</Value></NameValueList><NameValueList><Name>Colour</Name><Value>Grey Crush</Value></NameValueList></ItemSpecifics><ListingDuration>Days_7</ListingDuration><ListingType>FixedPriceItem</ListingType><PayPalEmailAddress>[email protected]</PayPalEmailAddress><PaymentMethods>PayPal</PaymentMethods><PictureDetails><PictureURL>https://www.suunto.com/globalassets/productimages/suunto-core-crush-new/core-crush-gray/ss020691000-suunto-core-crush-gray-perspective.png?height=550&format=jpeg&bgcolor=f6f6f6</PictureURL></PictureDetails><PostalCode>E15 1LB</PostalCode><PrimaryCategory><CategoryID>31387</CategoryID></PrimaryCategory><ProductListingDetails><EAN>45235909735</EAN></ProductListingDetails><Quantity>1</Quantity><ReturnPolicy><ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption><ReturnsWithinOption>Days_30</ReturnsWithinOption><ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption></ReturnPolicy><SKU>45235909735-180704-bcv-P013302-a</SKU><ShippingDetails><ShippingDetails><InternationalShippingServiceOption><ShippingService>Chronopost Express International</ShippingService><ShippingServiceCost>30.00</ShippingServiceCost><ShippingServicePriority>1</ShippingServicePriority></InternationalShippingServiceOption><ShipToLocations>Worldwide</ShipToLocations><ShippingType>Flat</ShippingType></ShippingDetails><ShippingServiceOptions><FreeShipping >1</FreeShipping ><ShippingService>UK_RoyalMailFirstClassStandard</ShippingService><ShippingServicePriority>1</ShippingServicePriority></ShippingServiceOptions><ShippingType>Flat</ShippingType></ShippingDetails><StartPrice>199.99</StartPrice><Title>Suunto 5061319 Core Grey Crush</Title></Item><Site>UK</Site></VerifyAddItemRequest>'

Solution

  • You need to escape the & characters (as in ...&bgcolor=...) into &amp; entity references. Otherwise, XML attempts to interpret &bgcolor as an entity reference, which isn't bound to anything in your context, and needs to be terminated by ; for valid XML anyway (but not SGML, which needs ; only if the next following character is a name character).