close

org.dom4j.DocumentException: Error on line 1 of document  : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.

 

我負責的是"PHP系統"

提供API給"JAVA系統"CALL

 

就算回傳空白字串

還是會有Content-length

然後錯誤訊息是"?"

 

那個問號question mark是因為沒辦法解析字元

 

用POSTMAN下載response發現檔案編碼是UTF-8 with bom

最後就是用ob_clean()清掉buffer

 

header('Content-type: text/html; charset=UTF-8'); // 編碼是UTF-8

 

ob_clean(); // 清掉後才會是沒有BOM的

 

header('Content-type: text/html; charset=UTF-8');
ob_clean();

// XML
$xmlstr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DATA></DATA>";
$sxe = new SimpleXMLElement($xmlstr);

$sxe->addChild('TODO_NAME', '');
$sxe->addChild('TODO_URL', $url . "/verifyLogin.php");
$sxe->addChild('TODO_COUNT', 0);
$with = $sxe->addChild('WITH');

print $sxe->asXML();

 

 

arrow
arrow

    小小朋 發表在 痞客邦 留言(0) 人氣()