XML Parse Error - Extra content at the end of the document

后端 未结 2 1253
傲寒
傲寒 2020-11-30 12:50

I am trying to give the option to get either a JSON or XML response.

JSON works fine but when I view the XML, I get an error.

http://lmsapi.com/?api_key=fba9

相关标签:
2条回答
  • XML can only have one "document entity" or "root", you're trying to use two (status and format). Wrap your two elements in a single one, so that your XML document only has one root element.

    Bad

    <?xml version="1.0"?>
    <status>success</status>
    <format>xml</format>
    

    Good

    <?xml version="1.0"?>
    <response>
      <status>success</status>
      <format>xml</format>
    </response>
    
    0 讨论(0)
  • 2020-11-30 13:05

    Make sure you also triple check for a duplicate urlset declaration at the top of your document. This was my problem. It was a very careless oversight.

        <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9" 
    url="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    
    0 讨论(0)
提交回复
热议问题