Using Databases and Handling XML
Using Databases and Handling XML
HANDLING XML
INTRODUCTION
mysqli_query(database,statement)
mysqli_fetch_object(result)
mysqli_fetch_row(result)
mysqli_fetch_array(result,type)
WHAT IS XML
Note:
Most programmers do not need all of the facilities of DOM implementation and
do not want to work at the level of a raw XML
They need a nice, clean interface which lets them to extract the information
from the XML documents
PHP 5 includes a extension called a SimpleXML to load and access the XML
documents
SIMPLE XML
simplexml_import_dom(object)
If the script contains an XML document as a DOM object, this
method will load the properties of that object into a
SimpleXMLElement object
simplexml_load_file(URI)
Generally the XML data in the script is a sting or a DOM object
Sometimes we want to load a file which contains the XML at
runtime
The file may be available on the local filesystem or remotely via a
URL
This method encapsulates all of the functionality which is needed
to find and import the file and to create the SimpleXMLElement
object
If the loading or importing the data fails the method returns false
The underlying implementation uses the Libxml 2 library
SimpleXMLElement->asXML()
It takes the properties of the SimpleXMLElement object and
returns an XML document which contains them
SimpleXMLElement ->attributes()
Returns the attributes of the object if any, these can be iterated
across using a foreach loop
SimpleXMLElement->children()
Returns the children, if any, of the object so that they can be
iterated across
SimpleXMLElement->xpath(expression)
This method accepts an Xpath expression as its parameter
The element is evaluated against the expression
The result is returned as an array of SimpleXMLElement object
END of PHP