Uploading Images on WordPress Using XML

The following XML code downloads an image attachment from a link and uploads it to the Media library. Initially I had erroneously thought that it might actually be creating a Course post.
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<!– This is a WordPress eXtended RSS file generated by WordPress as an export of your site. –>
<!– It contains information about your site’s posts, pages, comments, categories, and other content. –>
<!– You may use this file to transfer that content from one site to another. –>
<!– This file is not intended to serve as a complete backup of your site. –><!– To import this information into a WordPress site follow these steps: –>
<!– 1. Log in to that site as an administrator. –>
<!– 2. Go to Tools: Import in the WordPress admin panel. –>
<!– 3. Install the “WordPress” importer from the list. –>
<!– 4. Activate & Run Importer. –>
<!– 5. Upload this file using the form provided on that page. –>
<!– 6. You will first be asked to map the authors in this export file to users –>
<!–    on the site. For each author, you may choose to map to an –>
<!–    existing user on the site or to create a new user. –>
<!– 7. WordPress will then import each of the posts, pages, comments, categories, etc. –>
<!–    contained in this file into your site. –>

<!– generator=”WordPress/4.2.5″ created=”2015-10-01 08:30″ –>
<rss version=”2.0″
xmlns:excerpt=”http://wordpress.org/export/1.2/excerpt/&#8221;
xmlns:content=”http://purl.org/rss/1.0/modules/content/&#8221;
xmlns:wfw=”http://wellformedweb.org/CommentAPI/&#8221;
xmlns:dc=”http://purl.org/dc/elements/1.1/&#8221;
xmlns:wp=”http://wordpress.org/export/1.2/&#8221;
>

<channel>
<title>LMS Press</title>
<link>http://demo3.pressapps.co/lmspress</link&gt;
<description>Just another Demo 3 Sites site</description>
<pubDate>Thu, 01 Oct 2015 08:30:03 +0000</pubDate>
<language>en-US</language>
<wp:wxr_version>1.2</wp:wxr_version>
<wp:base_site_url>http://demo3.pressapps.co/</wp:base_site_url&gt;
<wp:base_blog_url>http://demo3.pressapps.co/lmspress</wp:base_blog_url&gt;

<wp:author><wp:author_id>13400</wp:author_id><wp:author_login>vjtestxml</wp:author_login><wp:author_email>test@test.com</wp:author_email><wp:author_display_name><![CDATA[Vjtest Xml]]></wp:author_display_name><wp:author_first_name><![CDATA[Vjtest]]></wp:author_first_name><wp:author_last_name><![CDATA[Xml]]></wp:author_last_name></wp:author>

<wp:category><wp:term_id>13</wp:term_id><wp:category_nicename>beauty</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Beauty]]></wp:cat_name></wp:category>
<wp:category><wp:term_id>9</wp:term_id><wp:category_nicename>cooking</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Cooking]]></wp:cat_name></wp:category>
<wp:category><wp:term_id>12</wp:term_id><wp:category_nicename>health</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Health]]></wp:cat_name></wp:category>
<wp:category><wp:term_id>14</wp:term_id><wp:category_nicename>music</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Music]]></wp:cat_name></wp:category>
<wp:category><wp:term_id>11</wp:term_id><wp:category_nicename>photography</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Photography]]></wp:cat_name></wp:category>
<wp:category><wp:term_id>1</wp:term_id><wp:category_nicename>uncategorized</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[Uncategorized]]></wp:cat_name></wp:category>
<wp:term><wp:term_id>20</wp:term_id><wp:term_taxonomy>event_category</wp:term_taxonomy><wp:term_slug>business</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Business]]></wp:term_name><wp:term_description><![CDATA[Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt utlam dolore magnam aliquam quaerat voluptatem unert enim ad minima veniam.]]></wp:term_description></wp:term>
<wp:term><wp:term_id>9</wp:term_id><wp:term_taxonomy>event_category</wp:term_taxonomy><wp:term_slug>cooking</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Cooking]]></wp:term_name><wp:term_description><![CDATA[Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt utlam dolore magnam aliquam quaerat voluptatem unert enim ad minima veniam.]]></wp:term_description></wp:term>
<wp:term><wp:term_id>5</wp:term_id><wp:term_taxonomy>product_type</wp:term_taxonomy><wp:term_slug>external</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[external]]></wp:term_name></wp:term>
<wp:term><wp:term_id>3</wp:term_id><wp:term_taxonomy>product_type</wp:term_taxonomy><wp:term_slug>grouped</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[grouped]]></wp:term_name></wp:term>
<wp:term><wp:term_id>22</wp:term_id><wp:term_taxonomy>event_category</wp:term_taxonomy><wp:term_slug>health-fitness</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Health &amp; Fitness]]></wp:term_name><wp:term_description><![CDATA[Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt utlam dolore magnam aliquam quaerat voluptatem unert enim ad minima veniam.]]></wp:term_description></wp:term>
<wp:term><wp:term_id>23</wp:term_id><wp:term_taxonomy>course_category</wp:term_taxonomy><wp:term_slug>health-fitness-2</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Health &amp; Fitness]]></wp:term_name><wp:term_description><![CDATA[Dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt utlam dolore magnam aliquam quaerat voluptatem unert enim ad minima veniam.]]></wp:term_description></wp:term>
<wp:term><wp:term_id>21</wp:term_id><wp:term_taxonomy>event_category</wp:term_taxonomy><wp:term_slug>lifestyle</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Lifestyle]]></wp:term_name><wp:term_description><![CDATA[Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt utlam dolore magnam aliquam quaerat voluptatem unert enim ad minima veniam.]]></wp:term_description></wp:term>
<wp:term><wp:term_id>14</wp:term_id><wp:term_taxonomy>course_category</wp:term_taxonomy><wp:term_slug>music</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Music]]></wp:term_name><wp:term_description><![CDATA[Porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt utlam dolore magnam aliquam quaerat voluptatem unert enim ad minima veniam.]]></wp:term_description></wp:term>
<wp:term><wp:term_id>11</wp:term_id><wp:term_taxonomy>course_category</wp:term_taxonomy><wp:term_slug>photography</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Photography]]></wp:term_name><wp:term_description><![CDATA[Cestqui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt utlam dolore magnam aliquam quaerat voluptatem unert enim ad minima veniam.]]></wp:term_description></wp:term>
<wp:term><wp:term_id>2</wp:term_id><wp:term_taxonomy>product_type</wp:term_taxonomy><wp:term_slug>simple</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[simple]]></wp:term_name></wp:term>
<wp:term><wp:term_id>4</wp:term_id><wp:term_taxonomy>product_type</wp:term_taxonomy><wp:term_slug>variable</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[variable]]></wp:term_name></wp:term>
<wp:term><wp:term_id>7</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>main</wp:term_slug><wp:term_name><![CDATA[Main]]></wp:term_name></wp:term>
<wp:term><wp:term_id>6</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>menu-1</wp:term_slug><wp:term_name><![CDATA[Menu 1]]></wp:term_name></wp:term>

<generator>http://wordpress.org/?v=4.2.5</generator&gt;

<item>
<title>Test cooking course</title>
<link>http://demo3.pressapps.co/lmspress/steaming-stewing-and-braising/cooking-course/</link&gt;
<pubDate>Wed, 18 Feb 2015 11:00:11 +0000</pubDate>
<dc:creator><![CDATA[vladka]]></dc:creator>
<guid isPermaLink=”false”>http://demo3.pressapps.co/lmspress/wp-content/uploads/sites/13522/2015/02/cooking-course.jpg</guid&gt;
<description></description>
<content:encoded><![CDATA[jumbalaya]]></content:encoded>
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
<wp:post_id>2106</wp:post_id>
<wp:post_date>2015-02-18 11:00:11</wp:post_date>
<wp:post_date_gmt>2015-02-18 11:00:11</wp:post_date_gmt>
<wp:comment_status>open</wp:comment_status>
<wp:ping_status>open</wp:ping_status>
<wp:post_name>test-cooking-course</wp:post_name>
<wp:status>inherit</wp:status>
<wp:post_parent>0</wp:post_parent>
<wp:menu_order>0</wp:menu_order>
<wp:post_type>attachment</wp:post_type>
<wp:post_password></wp:post_password>
<wp:is_sticky>0</wp:is_sticky>
<wp:attachment_url>http://demo3.pressapps.co/lmspress/wp-content/uploads/sites/13522/2015/02/cooking-course.jpg</wp:attachment_url&gt;
<wp:postmeta>
<wp:meta_key>_wp_attached_file</wp:meta_key>
<wp:meta_value><![CDATA[2015/02/cooking-course.jpg]]></wp:meta_value>
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_wp_attachment_metadata</wp:meta_key>
<wp:meta_value><![CDATA[a:5:{s:5:”width”;i:1600;s:6:”height”;i:1100;s:4:”file”;s:26:”2015/02/cooking-course.jpg”;s:5:”sizes”;a:7:{s:9:”thumbnail”;a:4:{s:4:”file”;s:26:”cooking-course-150×150.jpg”;s:5:”width”;i:150;s:6:”height”;i:150;s:9:”mime-type”;s:10:”image/jpeg”;}s:6:”medium”;a:4:{s:4:”file”;s:26:”cooking-course-300×206.jpg”;s:5:”width”;i:300;s:6:”height”;i:206;s:9:”mime-type”;s:10:”image/jpeg”;}s:5:”large”;a:4:{s:4:”file”;s:27:”cooking-course-1024×704.jpg”;s:5:”width”;i:1024;s:6:”height”;i:704;s:9:”mime-type”;s:10:”image/jpeg”;}s:14:”shop_thumbnail”;a:4:{s:4:”file”;s:26:”cooking-course-180×180.jpg”;s:5:”width”;i:180;s:6:”height”;i:180;s:9:”mime-type”;s:10:”image/jpeg”;}s:12:”shop_catalog”;a:4:{s:4:”file”;s:26:”cooking-course-300×300.jpg”;s:5:”width”;i:300;s:6:”height”;i:300;s:9:”mime-type”;s:10:”image/jpeg”;}s:11:”shop_single”;a:4:{s:4:”file”;s:26:”cooking-course-600×600.jpg”;s:5:”width”;i:600;s:6:”height”;i:600;s:9:”mime-type”;s:10:”image/jpeg”;}s:17:”thumbnail_800x550″;a:4:{s:4:”file”;s:26:”cooking-course-800×550.jpg”;s:5:”width”;i:800;s:6:”height”;i:550;s:9:”mime-type”;s:10:”image/jpeg”;}}s:10:”image_meta”;a:10:{s:8:”aperture”;i:0;s:6:”credit”;s:0:””;s:6:”camera”;s:0:””;s:7:”caption”;s:0:””;s:17:”created_timestamp”;i:0;s:9:”copyright”;s:0:””;s:12:”focal_length”;i:0;s:3:”iso”;i:0;s:13:”shutter_speed”;i:0;s:5:”title”;s:0:””;}}]]></wp:meta_value>
</wp:postmeta>
</item>
</channel>

</rss>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s