PHP创建XML节点

    $doc = new DOMDocument('1.0','utf-8');
    $bookshelf = $doc ->createElement('bookshelf');
    $doc ->appendChild($bookshelf);
    $book = $doc ->createElement('book');
    $title = $doc ->createElement('title');
    $title ->nodeValue = '天龙八部';
    $book ->appendChild($title);
    $bookshelf -> appendChild($book);
    $doc ->formatOutput = false;
    $doc ->save('newbook.xml');
?>

你可能感兴趣的:(PHP创建XML节点)