Simplexml_load_file (str file); Loads an XML document into a SimpleXML object, and this method returns a handle
Simplexml_load_string (str string); Loads an XML document into a SimpleXML object that returns a handle
Simplexml_import_dom (data) This function converts a DOM node to a SimpleXML object, where data is a useful DOM node
$simplexml->addattribute (name,value) adds a property to the SimpleXML object element, note that it is a SimpleXML object element, not a SimpleXML object handle.
$simplexml->addchlid (name,value) adds a child node to the specified XML node
$simplexml->asxml () returns an XML document from a SimpleXMLElement object as a string, which can be used as an XML document to save
$simplexml->attributes () returns an array of the properties of the SimpleXML element node of the PHP5 object.
Run the above code to print out the array ([@attributes] = = Array ([name] = cx,html [tt] = DDD))
As you can see, $simplexml->attributes () gets all the attributes of an XML element node, but is contained in a [@attributes] array, so it is obtained by $xml = $xml [' @attributes '].
$simplexml->children () returns an array of children of the SimpleXML object element node
$simplexml->__construct () to create a new XML document
$simplexml->getdocnamespaces () This function returns the namespace defined by the $simplexml object
$simplexml->getname () returns the name of the $simplexml object element, which is the label signature
$simplexml->getnamespaces () returns the namespace used by the $simplexml object
$simplexml->registerxpathnamespace () This function creates a namespace context for the next XPath query
$simplexml->xpath () uses the XPath syntax to parse a PHP5 object simplexml
Example code 1
- xml version="1.0 " encoding= "GBK"?>
- < Leapsoulxml >
- < Leapsoulinfo >
- < name > leapsoul-php Website Development name>
- < website > http://www.leapsoul.cn website>
- < Description > Share PHP website development and building fun and teach you how to build a website description>
- < Bloger > David bloger>
- < Date > 2009-05-13 date>
- < QQ > qq:154130270 qq>
- leapsoulinfo>
- < Leapsoulinfo >
- < name > leapsoul-php Website Development name>
- < website > http://www.leapsoul.cn website>
- < Description > Share PHP website development and building fun and teach you how to build a website description>
- < Bloger > David bloger>
- < Date > 2009-05-13 date>
- < QQ > qq:154130270 qq>
- leapsoulinfo>
- leapsoulxml>
We can combine the above PHP5 object SimpleXML example, plus our own understanding, should be able to fully understand this new function.
http://www.bkjia.com/PHPjc/446334.html www.bkjia.com true http://www.bkjia.com/PHPjc/446334.html techarticle simplexml_load_file (str file); Loads an XML document into a SimpleXML object, which returns a handle simplexml_load_string (str string); Load an XML document into a simple ...