Site icon Hip-Hop Website Design and Development

How to import nested categories from XML file?

We’re importing an eXtended RSS file generated by WordPress thru the native Importer:

Tools: Import in the WordPress admin panel

Importing parent posts is straightforward, by defining the respective parent id:

<wp:post_parent>1</wp:post_parent>

However, during the export the hierarchy of categories, subcategories and so on gets lost, and we’re trying to set the according parent categories inside xml file. We’ve tried the following without any success:

<category domain="docs_category" nicename="category-1"><![CDATA[Category]]></category>

And for another post:

<category domain="docs_category" nicename="subcategory-1" parent="category-1"><![CDATA[Subcategory]]></category>

We cannot find any explicit documentation regarding build of such WordPress RSS file.

Could someone please point out a link to the documentation on WordPress?

Moreover, the closest example we’ve found was on GitHub:

<wp:category>
        <wp:term_id>2</wp:term_id>
        <wp:category_nicename><![CDATA[test-category-1]]></wp:category_nicename>
        <wp:category_parent><![CDATA[]]></wp:category_parent>
        <wp:cat_name><![CDATA[Test Category 1]]></wp:cat_name>
</wp:category>
<wp:category>
        <wp:term_id>3</wp:term_id>
        <wp:category_nicename><![CDATA[test-subcategory-1]]></wp:category_nicename>
        <wp:category_parent><![CDATA[test-category-1]]></wp:category_parent>
        <wp:cat_name><![CDATA[Test Subcategory 1]]></wp:cat_name>
</wp:category>

We’re not working with the taxonomy domain="category", but wp:category_parent sets us on the right path.

The question is:

How to set the correct parent category for each channel item, i.e. each unique post individually?

Thanks in advance for any help on this kind of urgent matter!