php Convert XML to JSON in PHP
관련링크
본문
function XMLtoJSON($xml) {
$xml = file_get_contents($xml); // gets XML content from file
$xml = str_replace(array("\n", "\r", "\t"), '', $xml); // removes newlines, returns and tabs
// replace double quotes with single quotes, to ensure the simple XML function can parse the XML
$xml = trim(str_replace('"', "'", $xml));
$simpleXml = simplexml_load_string($xml);
return stripslashes(json_encode($simpleXml)); // returns a string with JSON object
}
페이지 정보
[ 조회 170회 ] 작성일15-06-02 23:34