Support

Account

Home Forums General Issues Export to XML and corrupted import due to message fields

Solved

Export to XML and corrupted import due to message fields

  • I’ve setup several message fields in order to help my users with tips, explanations, icons, etc.

    After working some time in a testing environment/template, I’ve decided to export those fields via XML to a brand new template, but what I’ve noticed is: every fieldgroup featuring at least 1 message field (they are usually containing HTML TAG such as <h1>, <p>, <i>, etc), doesn’t get imported correctly and shows completely empty (even if the importation process seems to proceed and end correctly).

    For example, this is a slide of code I’ve taken off a fieldgroup I’ve exported:

    
    
    <wp:postmeta>
    
        <wp:meta_key>field_52160d7bd6634</wp:meta_key>
        
        <wp:meta_value><![CDATA[a:9:{s:3:"key";s:19:"field_52160d7bd6634";s:5:"label";s:19:"MY MAIN 
    
    IMAGE";s:4:"name";s:0:"";s:4:"type";s:7:"message";s:12:"instructions";s:0:"";s:8:"required";s:1:"0";s:7:"messag
    
    e";s:465:"<div class="custom_acfpanel">
    <h2><i class="icon-camera-retro icon-4x"></i>MY MAIN IMAGE</h2>
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec 
    
    urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. </p>
    </div>";s:17:"conditional_logic";a:3:{s:6:"status";s:1:"0";s:5:"rules";a:1:{i:0;a:3:
    
    {s:5:"field";s:19:"field_5215f7eec394c";s:8:"operator";s:2:"==";s:5:"value";s:5:"noimg";}}
    
    s:8:"allorany";s:3:"all";}s:8:"order_no";i:0;}]]></wp:meta_value>
    
    </wp:postmeta>
    
    

    As you may notice, I’ve included <div>, <h2>, <i> and a <p> tags: they show graciously in my backend, but as long as I leave ’em there, I cannot import the fieldgrup. Infact, if I delete those tags via text editor (or via WP backend for all that matters), and leave only raw text, the importation process completes perfectly.

    I’m no expert, but it’s seems like the “![CDATA[]]” tag in “<wp:meta_value>” should already be able to nest any HTML code… so as long as I’m not mistaken, I don’t see why this is not working out as expected. I’ve decided then to keep searching on boards/forums/etc and I’ve stumbled upon an issue apparently similar to mine: “![CDATA[]]” tag didn’t really do the trick, but in the end they managed to solve their issues by using the HTML codes for “<” and “>” (“<” and “>”) for the nested HTML elements. But unfortunately, it didn’t work for me.

    So after scratching my head for quite a while, I now wonder: is there any way I can export via XML all my message fields containing HTML TAGS? Any way to work around this issue maybe using another import plugin, using a search/replace batch on the XML files or something similar? I’d prefer not to rely oven the PHP export tool, as it would require me – whenever I may need to edit my fields – to costantly edit/export/include back from another separate installation (the one I’m currently trying to copy the fields from).

    Thanks in advance!

  • Hi @foyle

    I have a feeling the issue is actually due to having a line break within the string.

    Can you remove all line breaks (html tags are fine). Does this then fix the import issue?

  • Thank you, removing line breaks indeed solved my problem.

    Yet I had to take one more step inbetween due to the previous (failed) import attempts. I tried to do as it follows:

    1) Delete the corrupted/failed import on the target WP installation
    2) Edit the original message field on the source WP installation in order to delete line-breaks
    3) Save
    4) Export as XML
    5) Import back

    But it didn’t work: even if I was actually importing a “line-break” free message field, either no fields were created on the target WP installation (as result of the new import procedure), or only one message field would show up… with line breaks.

    So I cloned the original fieldgroup (on the source WP installation) with Duplicate Post (http://wordpress.org/plugins/duplicate-post/), exported it, imported it back and… it worked.

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

The topic ‘Export to XML and corrupted import due to message fields’ is closed to new replies.