CakePHP는 배열 (CakePHP docu -> Core Libraries -> Utilities -> Xml ->Transforming an array into a string of XML)에서 XML 문서/문자열을 생성하는 기능을 제공합니다.CakePHP로 주석을 사용하여 XML을 생성하는 방법은 무엇입니까?
간단한 예 :
$xmlArray = array(
'project' => array(
'@id' => 1,
'name' => 'Name of project, as tag',
'@' => 'Value of project'
)
);
$xmlObject = Xml::fromArray($xmlArray);
$xmlString = $xmlObject->asXML();
결과 : 이제
<?xml version="1.0"?>
<project id="1">Value of project<name>Name of project, as tag</name></project>
이 같은 하나 개 이상의 의견이있는 XML을 생성하고 싶습니다 :
<?xml version="1.0"?>
<!-- here is a comment -->
<project id="1">Value of project<name>Name of project, as tag</name></project>
그것을인가 가능한? 그렇게하는 방법?
COMMENT :
이 질문은 "Is it possible to insert a comment tag into an xml using simplexml?"의 중복으로 표시되었습니다. 그러나 더 구체적이고 CakePHP XML 생성의 컨텍스트에서 XML 주석을 참조하고 "일반"PHP 또는 SimpleXML
이 아니기 때문에이 질문은 중복되지 않습니다.