PHP uses the DOMDocument class to generate HTML instances (including common tag elements ). In this section, we will learn how to use core PHP to generate HTML files. recently, when I was querying php.net, I found the DOMDocument class very
When using
The XML file used is also an example of XML in the article "How to use PHP XML to Process SimpleXML", the file name is: Me.xml. The code is as follows:
PHP XML processing XML code
? xml version = "1.0" encoding="utf-8"?>
Create a DOMDocument object using DOM extension, add elements to the document using the DOMDocument object method, and generate the document using the save () or saveXML () method, you can also use SimpleXML to quickly solve the problem... create a
A total of four files, respectively, is to create, add, delete, modify four functions, variables are written dead, change to a $_post way to receive it can be used
index.php Creating features
Copy CodeThe code is as follows:
$xmlpatch = '
New XML features of PHP5. Target Readers: This article is intended for PHP developers who are interested in the new XML functions of PHP5. We assume that the reader has basic knowledge about XML. However, if you are already targeting readers
This
Set of common phpxml functions (more detailed ). 1. Functions of DOM a and DOMDocument-load (): loads xml files. usage: DOMDocument-load (stringfilename) parameter: filename, xml file; return: TRUE if successful, error
1. DOM functions
A.
PHP reads and writes XML files. PHP can easily generate and read XML files. PHP mainly reads and writes XML through DOMDocument, DOMElement, and DOMNodeList. The following describes how to use PHP to easily generate and read XML files. PHP mainly
1. DOM functions
A, Domdocument->load ()
Role: Loading an XML file
Usage: domdocument->load (string filename)
Parameters: Filename,xml file;
Returns: TRUE if successful, or FALSE if unsuccessful.
B, Domdocument->loadxml ()
Role: Loading XML
The simplest case for reading XML in PHP:
The XML file (Cy.xml) is as follows:
Copy CodeThe code is as follows:
1
2
3
The php file (cy.php) is as follows:
Copy CodeThe code is as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.