Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @vampus2006,

    How can I remove tag from XML if data is empty?

    You’d have to use PHP to output the tag conditionally – see the bottom of this doc: https://www.wpallimport.com/documentation/export-wordpress-data-to-custom-xml-feed/.

    Here’s a really basic example function:

    function my_output_param( $value, $name ) {
    	$xml = '';
    	if ( ! empty( $value ) ) {
    		$xml .= '**LT**param name="' . $name . '"**GT**' . $value . '**LT**/param**GT**';
    	}
    	return $xml;
    }

    Example usage in the XML template:

    [my_output_param({Product Color},"Color")]

    Also, be sure to turn off CDATA tags in the “Advanced Options” section of the export any time you’re outputting custom XML with PHP.

    Thread Starter vampus2006

    (@vampus2006)

    Hi @wpallimport,

    Thanks a lot! It helped me a lot!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How remove empty tag from XML?’ is closed to new replies.