Can php dom be directly read and written in the current php xml without using DOMDocument-& gt; load & nbsp; can dom be used without using DOMDocument-& gt; load & nbsp; reads files from other locations, and directly reads the xml written in the
There are two traditional ways to deal with XML files: SAX and DOM. SAX based on the event trigger mechanism, a scan of the XML file, complete the processing to be done; Dom constructs the entire XML file as a DOM tree, which is processed by
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
There are many ways to write XML in PHP. Here we will mainly introduce the usage of domdocument, which is basically the same as that in JS. It is actually very simple.
There are four files in total: Create, add, delete, and modify. the variables are
Example 1: Loop all "artist" elements (NodeTypes = 1), find information about the correct artist output album The CD contains with the data that the JavaScript is sending to the matching name
XML file:
empire burlesque bob dylan usa
Acquisition is a lot of companies do the most thing, can quickly get others hard-earned data, although not moral, but can not be banned!Common ways to collect PHP are:
Regular acquisition.
Use DOM object acquisition.
Extracted using
There are four files in total: Create, add, delete, and modify. the variables are all written to death. You can use the $ _ POST method to receive the changes.
// Index. php creation Function
Copy codeThe Code is as follows: $ Xmlpatch = 'index. xml
Example:
DOM XML parser functions are part of the core of PHP. You can use these functions without installation.XML fileThe following XML file will be used in our example:
The code is as follows
Copy Code
I have to write a. XML file myself, but I have never used it. below is the content related to the XML operation class DOMDocument.
Attribute:
Attribute list of the Attributes storage node (read-only)
List of child nodes of the childNodes storage
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.