Title: Is element empty / has child function
Last modified: July 13, 2021

---

# Is element empty / has child function

 *  Resolved [dmaziarz](https://wordpress.org/support/users/dmaziarz/)
 * (@dmaziarz)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/is-element-empty-has-child-function/)
 * Hello,
    I’m looking for a function that checks if the element has any child (
   element inside element).
 * Structure XML:
 *     ```
       <sizes>
       <size>S</size>
       <size>L</size>
       </sizes>
       ```
   
 * So, basically I just want to check if <sizes> has <size> inside.
 * I’ve tried function below, but with no results:
 *     ```
        function is_element_empty($element) {
       	if(empty($element)) {
       		return "This element is empty.";
       	} else {
       		return "This element is not empty!";
       	}
       }
       ```
   
 * Thank you in advance
    -  This topic was modified 4 years, 11 months ago by [dmaziarz](https://wordpress.org/support/users/dmaziarz/).

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

 *  Thread Starter [dmaziarz](https://wordpress.org/support/users/dmaziarz/)
 * (@dmaziarz)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/is-element-empty-has-child-function/#post-14655062)
 * Solution was to put`{sizes[1]/size[1]}` as $element into `is_element_empty` function.
 *  [Iamhere](https://wordpress.org/support/users/iamhere/)
 * (@iamhere)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/is-element-empty-has-child-function/#post-14695690)
 * [@dmaziarz](https://wordpress.org/support/users/dmaziarz/)
 * > Solution was to put{sizes[1]/size[1]} as $element into is_element_empty function.
 * I need something similar. Can you provide an example of how you wrote the exact
   function please?
    -  This reply was modified 4 years, 10 months ago by [Iamhere](https://wordpress.org/support/users/iamhere/).
 *  Thread Starter [dmaziarz](https://wordpress.org/support/users/dmaziarz/)
 * (@dmaziarz)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/is-element-empty-has-child-function/#post-14696085)
 * [@iamhere](https://wordpress.org/support/users/iamhere/) Hello
    My function is
   to check if element <sizes> has something inside. Then it returns “visible” or“
   hidden”. You have to add it into “Function Editior” in WP All Import’s import
   settings.
 *     ```
       function is_element_empty($element) {
       	if(empty($element)) {
       		return 'hidden';
       	} else {
       		return 'visible';
       	}
       }
       ```
   
 * To use it just put this `[is_element_empty({sizes[1]/size[1]})]` into WP All 
   import field. The content between { and } is XPATH to your field the XML file.
    -  This reply was modified 4 years, 10 months ago by [dmaziarz](https://wordpress.org/support/users/dmaziarz/).

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

The topic ‘Is element empty / has child function’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

## Tags

 * [child](https://wordpress.org/support/topic-tag/child/)
 * [empty](https://wordpress.org/support/topic-tag/empty/)

 * 3 replies
 * 2 participants
 * Last reply from: [dmaziarz](https://wordpress.org/support/users/dmaziarz/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/is-element-empty-has-child-function/#post-14696085)
 * Status: resolved