Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
write XML line by line
#1
Hi everyone, this is my first post. Thanks for this great CMS and the community behind.

(english is not my mother language so, please, forget me for my poor spelling)

I use GIT for versioning my sites and the problem are the XMLs in one big line, so I decide break it tag by tag.

In admin/inc/caching_functions.php, at the end of file after saving the data:

Code:
$xml->asXML($filem);
    
    // PATCH XML line by line
    $tmpXMLfile = file_get_contents($filem);
    $tmpNTC = "###DONT_BREAK_CDADA###";
    
    // insert between the opening TAG and CDATA, and the closing too.
    $tmpXMLfile = str_replace("><![CDATA",">$tmpNTC<![CDATA",$tmpXMLfile);
    $tmpXMLfile = str_replace("]]></","]]>$tmpNTC</",$tmpXMLfile);
    
    // insert new line (linux) between ><
    $tmpXMLfile = str_replace("><",">\n<",$tmpXMLfile);
    
    // clean DONT_BREAK_CDATA and write the file again.
    $tmpXMLfile = str_replace("$tmpNTC","",$tmpXMLfile);
    file_put_contents($filem,$tmpXMLfile);



Now, every change made with de admin panel will write XMLs TAGs separated by lines and can be follow the diffs with GIT or another version control system.

I hope this will be useful to somebody.

Best.
Reply


Messages In This Thread
write XML line by line - by almendro - 2015-08-12, 00:29:09
RE: write XML line by line - by Angryboy - 2015-08-12, 03:45:05
RE: write XML line by line - by almendro - 2015-08-12, 06:48:37
RE: write XML line by line - by shawn_a - 2015-08-12, 08:37:44
RE: write XML line by line - by Angryboy - 2015-08-12, 18:30:32
RE: write XML line by line - by shawn_a - 2015-08-12, 22:10:10
RE: write XML line by line - by shawn_a - 2015-08-13, 04:03:26
RE: write XML line by line - by almendro - 2015-08-13, 22:53:21
RE: write XML line by line - by Angryboy - 2015-08-13, 04:44:11
RE: write XML line by line - by almendro - 2015-08-13, 13:16:57
RE: write XML line by line - by shawn_a - 2015-08-13, 23:03:34



Users browsing this thread: 1 Guest(s)