错误:对实体“格式”的引用必须以\'; \'分隔符结尾。

时间:2018-11-22 09:14:32

标签: python xml escaping entity

在此处快速操作。我收到以下XML解析错误:

'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'}

很显然,我需要对XML字符串中的内容进行转义,但是我找不到实体"format"所指的内容。

有什么想法吗?

完整的XML字符串在这里:

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>alexbowles@gmail.com</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>'

1 个答案:

答案 0 :(得分:1)

您需要将&个字符(如...&bgcolor=...中的字符)转义到&amp;实体引用中。否则,XML会尝试将&bgcolor解释为实体引用,它在您的上下文中不受任何约束,并且对于有效的XML,无论如何都需要由;终止(但SGML则需要{ {1}}(仅当下一个字符是名称字符时)。