php DOMDocument removeChild 删除节点函数
domdocument
Delete node
本款教程实例是一款利用了 DOMDocument 的getElementById查询到指定的经删除节点,然后用removeChildm删除指定xml节点bi.
php DOMDocument removeChild 删除节点函数实例代码如下:
public function deletecomment($id) { $xml = new domdocument(); $xml->validateonparse=true; $xml->loadxml($this->getcontents(true)); $message = $xml->getelementbyid($id); $parentnode = $message->parentnode; $parentnode->removechild($message); $this->putcontents($xml->savexml()); }
Copy after login
xml 文档:
<?xml version="1.0" encoding="utf-8" <!doctype messages [ <!element messages (message)*> <!element message (name , website? , comment , date , user_ip? , user_agent? , spam)> <!attlist message mid id #required> <!element name (#pcdata)> <!element website (#pcdata)> <!element comment (#pcdata)> <!element date (#pcdata)> <!element spam (#pcdata)> <!element user_ip (#pcdata)> <!element user_agent (#pcdata)> ]> <messages> </messages>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
1 months ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
1 months ago
By DDD
R.E.P.O. Best Graphic Settings
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
1 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
