如何訪問php dom api
PHP DOM API不提供專用功能來檢索InnerHTML。與JavaScript不同,其中InnerHtml是元素的屬性,在PHP DOM中,您需要在節點的孩子上手動迭代以構建InnerHtml。
Example UsageAssuming you have an HTML string stored in $html_string, here's how you can implement this function:
$dom = new DOMDocument(); $ dom-> preservewhitespace = false; $ dom-> formatOutput = true; $ dom-> load($ html_string); $ domtables = $ dom-> getElementsBytagName(“ table”); foreach($ domtables作為$表) { Echo Dominnerhtml($ table); }
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3