converting xml data to array in cakephp

Achtepa

New Member
i am using the predefined function XML component of cakephp.what i want to do is, to convert xml file data into an array for processing purpose. fot this my code is like:\[code\]App::import('Helper', 'Xml');$xml = new XmlHelper();$xml_data = http://stackoverflow.com/questions/11323973/& new XML($filePath);$array = Set::reverse($xml_data);\[/code\]This code is working perfectly if my xml file contains data in format:\[code\]<parent> <tag ...../> <tag ...../></parent>\[/code\]where is root node.i.e all the tags are within a single parent tag.But the problem occurs when data is distributed in several different parent tags i.e:\[code\]<parent> <tag ...../></parent><parent> <tag ...../></parent>\[/code\]In this case only the data from the first parent tag is given in the output array.I know that a xml file should have only 1 root node, but the problem is that while i am reading a xml file sometimes i get files with multiple root nodes.What i just want to know is that is there any way to read a xml file with multiple root nodes.Is this any other way using which i can read multiple parent tags in a xml file
 
Back
Top