KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have 2 files 1.xml and 2.xml both having similar structure and I would like to have one. I tried many solutions but I had errors only - frankly speaking I have no idea how those scripts worked. 1.xml : <res> <items total="180"> <item> <id>1</id> <title>Title 1</title> <author>Author 1</author> </item> ... </items> </res> 2.xml : <res> <items total="123"> <item> <id>190</id> <title>Title 190</title> <author>Author 190</author> </item> ... </items> </res> I would like to create a new file merged.xml with the following structure <res> <items total="303"> <item> <id>1</id> <title>Title 1</title> <author>Author 1</author> </item> ... //items from 1.xml <item> <id>190</id> <title>Title 190</title> <author>Author 190</author> </item> ... //items from 2.xml </items> </res> How should I do that? Can you explain me the way to do it? How can I do it with more files? Thanks Edit What I tried? <?php function mergeXML(&$base, $add) { if ( $add->count() != 0 ) $new = $base->addChild($add->getName()); else $new = $base->addChild($add->getName(),
Tags (comma-separated)
Save Edits
Cancel