php Dynmically format xml to php array

wavaddertaistz

New Member
Hi I was wondering if anyone knows a script or function that can format any xml file to a array in a specific format such as having a xml something like this (but much longer)\[code\]<data> <width>3.5</width> <height>2</height> <edge>.125</edge> <safe>.125</safe></data><fold> <show_lines></show_lines> <type>online</type></fold><preview> <name>testfile</name> <location>testurl.com</location></preview><preview> <name>myfile</name> <location>someurl.com</location> <special>frontandback</special></preview>\[/code\]Id basically want to loop through each attribute check if there is more inside of it and so on and so on and basically create a array so it would look like so\[code\]$array = [data] ( width=>3.5 height=>2 edge=>.125 safe=>.125)[fold] ( type=>online)[preview] ( [0]=>( name=>testfile location=>testurl.com ) [1]=>( name=>myfile location=>someurl.com special=>frontandback ))\[/code\]and so on so basically it will only grab the elements that have values and skip the ones that dont and some parts of the xml may have more children than the other part and it should grab them all and if there is multiple attributes with same name that would be a array of its own with each one being a array inside of itHope that makes sense can anyone help please. Im mainly trying to use simplexml but can use anythign else
 
Back
Top