第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

多姆文檔避免初始 xml 標(biāo)記

多姆文檔避免初始 xml 標(biāo)記

PHP
慕虎7371278 2022-09-17 22:23:42
問(wèn)題:如何避免多姆文檔創(chuàng)建初始 xml 標(biāo)記?<?xml version="1.0"?>想要的代碼:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  <head>    <title>My site</title>  </head>  <body>  </body></html>使用 DOM 文檔生成的代碼:<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />    <title>My site</title>  </head>  <body></body></html>我的腳本:<?php/** * Ref: * https://stackoverflow.com/questions/19482826/using-domdocument-to-create-elements-in-an-html-file * https://www.php.net/manual/en/domimplementation.createdocumenttype.php */// Creates an instance of the DOMImplementation class$imp = new DOMImplementation; // Doctype $dtd = $imp->createDocumentType(   'html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' );// Base document$doc = $imp->createDocument("", "", $dtd);$doc->formatOutput = true;/** * Construct tag skeleton. */// [L-1]$html=$doc->appendChild(  $doc->createElementNS("http://www.w3.org/1999/xhtml","html"));$html->setAttribute("lang", "en");$html->setAttribute("xml:lang", "en");$doc->appendChild($html);    // [L-2]    $head=$html->appendChild(      $doc->createElement('head')    );        // [L-3]        $title=$head->appendChild(          $doc->createElement(            'title',            "My site"          )        );    // [L-2]    $body=$html->appendChild(      $doc->createElement('body')    );// Saveecho $doc->saveHTML();$doc->save("auto_produced_xhtml.xhtml");
查看完整描述

1 回答

?
動(dòng)漫人物

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超10個(gè)贊

您可以使用 而不是 ...另存為文件。取代saveHTMLFile();save()

$doc->save("auto_produced_xhtml.xhtml");

$doc->saveHTMLFile("auto_produced_xhtml.xhtml");

https://www.php.net/manual/en/domdocument.savehtmlfile.php


查看完整回答
反對(duì) 回復(fù) 2022-09-17
  • 1 回答
  • 0 關(guān)注
  • 106 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)