search
Homephp教程php手册php DOMDocument removeChild 删除节点函数

本款教程实例是一款利用了 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()); 
}

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>


Statement
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

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function