php涓瓁ml鏂囦欢鎬庝箞鍒涘缓
鍦≒HP涓垱寤篨ML鏂囦欢鏈夊绉嶆柟娉曪紝浠ヤ笅鏄叾涓殑涓€绉嶅父鐢ㄦ柟娉曪細
<?php
// 鍒涘缓涓€涓柊鐨刋ML鏂囨。
$doc = new DOMDocument();
// 鍒涘缓鏍瑰厓绱?/span>
$root = $doc->createElement("root");
$doc->appendChild($root);
// 鍒涘缓瀛愬厓绱?/span>
$child = $doc->createElement("child");
$root->appendChild($child);
// 娣诲姞瀛愬厓绱犵殑鏂囨湰鍐呭
$text = $doc->createTextNode("Hello, World!");
$child->appendChild($text);
// 淇濆瓨XML鏂囦欢
$doc->save("example.xml");
echo "XML鏂囦欢鍒涘缓鎴愬姛";
?>
浠ヤ笂浠g爜浼氱敓鎴愪竴涓畝鍗曠殑XML鏂囦欢example.xml
锛屽唴瀹瑰涓嬶細
<root>
<child>Hello, World!</child>
</root>