Jump to content

cleaning up an xml file


digitalgod

Recommended Posts

hey guys,

 

I was just wondering if there was a way to clean up the code in an xml file. Right now I'm using SimpleXML to add child nodes and whenever one gets appended it doesn't add a new line nor an indent, so it ends up looking something like this

 

<book>foo</book><book>bar</book>

Link to comment
https://forums.phpfreaks.com/topic/96592-cleaning-up-an-xml-file/
Share on other sites

I actually did try tidy but it didn't seem to do anything to the code... and libtidy is already installed on the server

 

this is what I tried, after writing to an xml file

$tidy_options = array(
			'input-xml'    => true,
			'output-xml'   => true,
			'indent'       => true,
			'indent-cdata' => true,
			'wrap'         => false,
		);
		$tidy = new tidy();
		$tidy->parseFile('file.xml', $tidy_options);
		$tidy->cleanRepair();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.