There are two traditional approaches to processing XML files: SAX and DOM.
1 SimpleXML introduction
There are two traditional approaches to processing XML files: SAX and DOM. Based on the event trigger mechanism,
Scan the XML file once to complete
Author: samisaThe following table lists the translation names:Payload: conversation contentObject: instanceFunction: functionUse php to Implement Network ServicesFramework: WSO2 WSF/PHPInstallation environment: windows or linux(I hate Computer
This article is to share the content of PHP commonly used function encapsulation, interested friends can have a look
1. Determine if the request is HTTP or HTTPS
$http _type = ((Isset ($_server[' https ") && $_server[' https '] = = ' on ') | |
SaveXML () function: Place an internal XML document into a string; for Example: "Test.xml" Tovejanireminderdon ' t forget me this weekend! $xmlDoc =new DOMDocument (); $xmlDoc->load ("Test.xml");p rint $xmlDoc->savexml (); Output:tove Jani Reminder
1 SimpleXML Introduction
There are two traditional ways to work with XML files: SAX and Dom. SAX is based on the event triggering mechanism,
The XML file is scanned for processing, and the DOM constructs the entire XML file as a DOM
Tree, through
Author: samisa
The following table lists the translation names:
Payload: conversation content
Object: instance
Function: function
Use php to Implement Network Services
Framework: WSO2 WSF/PHP
Installation environment: windows or linux
(I hate
The XML file has axis generated:
{"Code": "2", "Message": "Enterprise name and Enterprise registration number Match"}
I want to get the content of Ns1:checkqyreturn.
How
1 SimpleXML Profile
There are two traditional ways to deal with XML files: SAX and Dom. SAX is based on the event triggering mechanism,
A scan of the XML file completes the processing to be done; the DOM constructs the entire XML file as a DOM
Tree
SimpleXML provides a simple and fast method of XML operation, which greatly improves the efficiency of XML operation. But sometimes careless can bring a little trouble, look at the following code:
$xml = simplexml_load_string (
Title
XML cannot be parsed & amp;. how can this problem be solved? PHPcode $ str1 & quot; user. qzone. qq. com1340477530 #! App2 & amp; pos1300412602 & quot; $ xml & lt ;? Xmlversion & quot; 1.0 & quot; encoding & quot; UTF-8 & quot; XML cannot be parsed.
XML cannot be parsed & amp;. how can this problem be solved? PHPcode $ str1 & quot; user. qzone. qq. com1340477530 #! App2 & amp; pos1300412602 & quot; $ xml & lt ;? Xmlversion & quot; 1.0 & quot; encoding & quot; UTF-8 & quot ;? & G XML cannot be
SimpleXML provides a simple and fast XML operation method, greatly improving the efficiency of XML operations. But sometimes it may cause a lot of trouble if you are not careful. Check the following code:
$ Xml = simplexml_load_string ( title );
$
1 SimpleXML Introduction There are two traditional approaches to processing XML files: SAX and DOM. Based on the event trigger mechanism,Scan the XML file once to complete the processing. DOM constructs the entire XML file into a DOMTo process the
Some notes about SimpleXML. SimpleXML provides a simple and fast XML operation method, greatly improving the efficiency of XML operations. But sometimes it may cause a lot of trouble to be careful. look at the following code: $ xmls SimpleXML
Let's use a piece of code to reproduce the problem.
At first glance, the result is puzzling:
Copy Code code as follows:
$string =
hello
world
EOF;
$data = simplexml_load_string ($string);
Print_r ($data);
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
This example describes the use of the SimpleXML function in PHP, which allows you to transform XML into objects and share them for your reference. The specific analysis is as follows:
The SimpleXML function allows you to convert XML to an object,
A large number of smiplexml functions can be used to load and parse a large number of XML documents.
--------------------------------------------------------------------------------
1.
simplexml_load_file ()function to load the specified XML file
This article is related to the pitfalls encountered in the automatic reply of messages introduced by xiaobian. It is frequently encountered in daily project development and has reference value, if you are interested, study together.
Reply principle:
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.