Hi all, this is a basic tutorial on how to parse xml file in cakephp.
We all know that cakephp vastly utilizes the array concept in php. Here, I am going to explain you how to parse XML in CakePHP and convert it into an array.
Step1:
Get the XML Feed; for example you might be having an xml feed from a search engine or any other type of feed which is in xml. get the contents of the URL to do so, I’m going to create a function in my controller and utilize the XML helper.
create the function, say: parse_xml
to get the array to a variable
We all know that cakephp vastly utilizes the array concept in php. Here, I am going to explain you how to parse XML in CakePHP and convert it into an array.
Step1:
Get the XML Feed; for example you might be having an xml feed from a search engine or any other type of feed which is in xml. get the contents of the URL to do so, I’m going to create a function in my controller and utilize the XML helper.
create the function, say: parse_xml
function parse_xml() {
App::import('Xml');That’s all.. everything done
$raw_xml = file_get_contents("type your xml url here");
$parsed_xml = & new XML($raw_xml);
$parsed_xml = Set::reverse($parsed_xml); // reversing the xml to array. this can be also used to convert an array to xml also.
return $parsed_xml;
}
to get the array to a variable
$xml_array = $this->parse_xml();now try printing the array
echo "";
print_r($xml_array)die;
More Here
Courtesy:http://cakeleak.wordpress.com/2010/05/28/how-to-parse-xml-in-cakephp/
Very nice
ReplyDeletepython training in bangalore
corporate training companies in bangalore
This comment has been removed by the author.
ReplyDeletevery nice interview questions
ReplyDeletevlsi interview questions
extjs interview questions
laravel interview questions
sap bi/bw interview questions
pcb interview questions
unix shell scripting interview questions
Nice questions
ReplyDeletesap partner companies in bangalore
sap implementation companies in bangalore
sap partners in india
aws staffing
ReplyDeleteHi Your Blog is very nice!!
Get All Top Interview Questions and answers PHP, Magento, laravel,Java, Dot Net, Database, Sql, Mysql, Oracle, Angularjs, Vue Js, Express js, React Js,
Hadoop, Apache spark, Apache Scala, Tensorflow.
Mysql Interview Questions for Experienced
php interview questions for freshers
php interview questions for experienced
python interview questions for freshers
tally interview questions and answers
codeingniter interview questions
cakephp interview questions
express Js interview questions
react js interview questions
laravel Interview questions and answers