array2xml icon indicating copy to clipboard operation
array2xml copied to clipboard

Always use CDATA for tag content

Open tasso85 opened this issue 8 years ago • 0 comments

For the sake of consistency, wouldn't be better to always use CDATA blocks for the tag content?

In this way, the value supplied can always be used as is, and will never require any escaping (even if performed automatically).

Also, this would get rid of the # prefix.

Finally, when a tag has both attributes and a value, it should be possible to get rid of both ! and % prefixes by using the first value with numeric key as the value for the tag, that is, instead of

'photos' => array(
  'photo' => array(
	  0 => array(
		  '@mainphoto' => '1',
		  '%' => '1.png',
	  ),
	  1 => array(
		  '@mainphoto' => '0',
		  '%' => '2.png',
	  ),
	  2 => array(
		  '@mainphoto' => '0',
		  '%' => '3.png',
	  )
  )
)

it should be sufficient to write

'photos' => array(
  'photo' => array(
	  0 => array(
		  '@mainphoto' => '1',
		  '1.png',
	  ),
	  1 => array(
		  '@mainphoto' => '0',
		  '2.png',
	  ),
	  2 => array(
		  '@mainphoto' => '0',
		  '3.png',
	  )
  )
)

tasso85 avatar Sep 27 '17 10:09 tasso85