Error on line 2 at column 1: Extra content at the end of the document

前端 未结 4 1668
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 11:03

When I use the below code and parse the xml locally it works fine but when upload the same script at the server it shows error.

Note: I retrieved the $lng

4条回答
  •  旧巷少年郎
    2020-12-10 11:17

    On each loop of the result set, you're appending a new root element to the document, creating an XML document like this:

    
    ...
    ...
    ...
    

    An XML document can only have one root element, which is why the error is stating there is "extra content". Create a single root element and add all the mycatch elements to that:

    $root = $dom->createElement("root");
    $dom->appendChild($root);
    // ...
    while ($row = @mysql_fetch_assoc($result)){
      $node = $dom->createElement("mycatch");
      $root->appendChild($node);
    

提交回复
热议问题