• Niura

    (@niura)


    hi, hoping to pick the right section of the support forum i have these things to ask about…

    i have to import file from an XML not created by wordpress so i try to make the one passed to my similar to the wordpress one… i’m quite done, but i have one last issue…

    in the theme i use there’s a custom field about thumbs and i don’t understand how this works…

    the a parameter is the number of pic
    i is the current image
    and s??? is a parameter of my theme or is a parameter of wordpress? and if is a WP what is this?

    example :

    <wp:postmeta>
    <wp:meta_key>thumbs</wp:meta_key>
    <wp:meta_value><![CDATA[a:6:{i:0;s:75:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-1-300x201.jpg";i:1;s:75:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-2-300x201.jpg";i:2;s:75:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-3-201x300.jpg";i:3;s:75:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-4-300x201.jpg";i:4;s:67:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-5.jpg";i:5;s:67:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-6.jpg";}]]></wp:meta_value>
    <wp:postmeta>
    <wp:meta_key>thumbs</wp:meta_key>
    <wp:meta_value><![CDATA[a:7:{i:0;s:80:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-1-sogg-300x225.jpg";i:1;s:82:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-2-cucina-300x225.jpg";i:2;s:81:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-3-antib-225x300.jpg";i:3;s:81:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-4-bagno-225x300.jpg";i:4;s:80:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-8-matr-300x225.jpg";i:5;s:83:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-12-camera-300x225.jpg";i:6;s:83:"https://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-15-sottot-225x300.jpg";}]]></wp:meta_value>
    </wp:postmeta>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    The value is a serialized array. Don’t bother trying to make sense of it. It’s not that hard but unnecessary. There maybe some XML function that deals with this data type easily, for lack of better information, extract the CDATA content as a string, the part inside but not including the square brackets. PHP string manipulation functions can do this. Pass the extracted string to unserialize(). A properly structured array is returned that you can manipulate and access values as is normal for any array.

    Thread Starter Niura

    (@niura)

    one more question…

    i created the xml compatible file ad i test it importing with WP Tool.
    now i’d like to do one more step…

    every night is given me an XML file and via and running an authomatic PHP file i create the wordpress compatible XML file.
    can i create a PHP file that retrive the new XML file and insert the new (eventual) articles?

    there’s something to be inspired by (or better, someone already did something like this?)?

    thank you very much!

    Moderator bcworkz

    (@bcworkz)

    You can almost certainly automate the entire process. The only unknown for me is exactly how you access the nightly XML file, your script needs to determine the exact URL, that may be stupid simple or a complete pain. That established, use file_get_contents().

    To generate WP content from the XML data, try examining the WordPress Importer plugin for inspiration. It restores content saved as XML data by the Tools>Export utility

    Thread Starter Niura

    (@niura)

    You can almost certainly automate the entire process. The only unknown for me is exactly how you access the nightly XML file, your script needs to determine the exact URL, that may be stupid simple or a complete pain. That established, use file_get_contents().

    the XML is provided me by FTP (the client put the XML file on a FTP space and the file name is always the same…and everynight automatically he reupload a new file).
    i’ll give a look at the importer…and……another thing xD.

    if an article is already present the importer doesn’t import the article (right?).

    the best strategy is remove all the posts by the author i’m importing and then reimporting all?

    (something like DELETE * FROM wp_posts WHERE post_author = [AUTHOR_CODE])

    Moderator bcworkz

    (@bcworkz)

    I’ve never looked closely at the importer code — I don’t know. You can always create code to do exactly what you want. If you can be assured the download will always contain all of a particular author’s work, deleting all existing content is an easy way to avoid duplicates.

    I personally never liked the idea wiping out perfectly good data in order to restore it again from supposedly reliable but occasionally flawed data. The alternative of course is to check for duplicates before inserting each article. Or maybe only inserting articles dated after the previous download, assuming dating works that way. The best approach would depend on the nature of the data.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘xml importing’ is closed to new replies.