• Resolved Mike

    (@michael-copestake)


    Hi,

    I’m creating an XML feed, using the custom XML format, that needs to list images like this:

    <images>
    	<image id="1">
    		<url>http://domain.com/imagefile.jpg</url>
    	</image>
    </images>

    There doesn’t seem to be a way to do this using the XML Editor, so I’ve written a custom function which looks like this:

    function image( $url = null) {
    	$i = 1;
    	foreach ( $url as $image ) {
    		$output .= '<image id="' . $i . '"><url>' . $image . '</url\></image>';
    		$i++;
    	}
    	return htmlentities($output);
    }

    I’ve tried various different things, and it’s always output as text rather than XML, so isn’t passing validation.

    Any help to get this working as needed would be greatly appreciated.

    Thank you,
    Mike

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

    (@wpallimport)

    Hey @michael-copestake

    Please try this code instead:

    function image( $url = null) {
    	$i = 1;
    	$output = '';
    	foreach ( $url as $image ) {
    		$output .= '**LT**image id="' . $i . '"**GT**';
    		$output .= '**LT**url**GT**' . $image . '**LT**/url**GT**';
    		$output .= '**LT**/image**GT**';
    		$i++;
    	}
    	return $output;
    }

    Usage:

    <images>[image({Image URL})]</images>

    Thread Starter Mike

    (@michael-copestake)

    @wpallimport thank you!

    That worked! I had another look through the documentation and couldn’t see it anywhere though, perhaps the docs can be updated for WP All Export to be a bit more thorough.

    I appreciate your quick response though, I’ll mark this as resolved now.

    Plugin Author WP All Import

    (@wpallimport)

    Hey @michael-copestake

    I had another look through the documentation and couldn’t see it anywhere though, perhaps the docs can be updated for WP All Export to be a bit more thorough.

    Yes, agreed – this is definitely something we’re working on.

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

The topic ‘Export Images as Nested Elements’ is closed to new replies.