Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /home/cikul/public_html/dhika/wp-includes/wp-db.php on line 3021
Dhika Cikul » Blog Archive » [PHP] Extract XML Data

[PHP] Extract XML Data

Posted by cikul | Posted in PHP, Programming | Posted on 24-07-2012-05-2008


XML was designed to transport and store data. The design goals of XML emphasize simplicity, generality, and usability over the Internet.

It is a textual data format with strong support via Unicode for the languages of the world. Although the design of XML focuses on documents, it is widely used for the representation of arbitrary data structures, for example in web services.

XML Example :

<body>Don't forget me this weekend!</body>

back to the core of the article, how to read XML data from PHP?  PHP 5 has build in class to read XML data using DOMDocument Class. For example :

//extract XML to array
$dom = new domDocument;
$xml = (array)simplexml_import_dom($dom);

The output will be :

 [to] => Tove
 [from] => Jani
 [heading] => Reminder
 [body] => Don't forget me this weekend!

Share and Enjoy

Comments posted (1)

nice. thanks :D

Write a comment