nathanblogs Posted November 2, 2007 Share Posted November 2, 2007 Hello, Does any know an associative array to XML function? At the moment I'm creating a associative array from a xml file, for example <root> <name>test</name> <age>20</age> <city>perth</city> </root> would turn into array(1) { ["ROOT"]=> array(1) { [0]=> array(3) { ["NAME"]=> array(1) { [0]=> array(1) { ["VALUE"]=> string(4) "test" } } ["AGE"]=> array(1) { [0]=> array(1) { ["VALUE"]=> string(2) "20" } } ["CITY"]=> array(1) { [0]=> array(1) { ["VALUE"]=> string(5) "perth" } } } } } Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 2, 2007 Share Posted November 2, 2007 see this url http://www.phpfreaks.com/script/view/202.php Mod edit: email tags removed. Quote Link to comment Share on other sites More sharing options...
nathanblogs Posted November 5, 2007 Author Share Posted November 5, 2007 I'm looking to go from an array to xml, I can already go from xml to array. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 here you go http://www.phpclasses.org/browse/package/2286.html Quote Link to comment Share on other sites More sharing options...
nathanblogs Posted November 5, 2007 Author Share Posted November 5, 2007 Thanks, but they don't work the same way . I have moved on and I am now trying to achieve what I was doing with simpleXML instead of using arrays. basically I'm trying to modify an xml file based on the parent nodes it has for example I might have something like this <root> <nav> <ref>name1</ref> <parent>name2</parent> <item>a heap of irrelevant information</item> </nav> <nav> <ref>name2</ref> <parent></parent> <item>a heap of irrelevant information</item> </nav> </root> would be modified to <root> <nav> <ref>name2</ref> <parent></parent> <item> <nav> <ref>name1</ref> <parent>name2</parent> <item>a heap of irrelevant information</item> </nav> </item> <item>a heap of irrelevant information</item> </nav> </root> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.