/**
     * Work with the xml file
     * @param  array $args Fields from AJAX Post.
     * @return mixt
     */
    public function moove_read_xml($args)
    {
        $return_array = array();
        if ($args['type'] === 'url') {
            $xml = simplexml_load_file($args['data']);
        } else {
            $xml = simplexml_load_string(wp_unslash($args['data']));
        }
        if ($args['xmlaction'] === 'check') {
            if ($xml) {
                $parent = $parent . "/" . $xml->getName();
                Moove_Importer_Controller::moove_recurse_xml($xml, $parent);
                // $this->xmlnodes = array_unique( $this->xmlnodes );
                ob_start();
                ?>
                <h4><?php 
                _e('Select your repeated XML element you want to import', 'moove');
                ?>
</h4>
                <select name="moove-xml-nodes" id="moove-xml-nodes" class="moove-xml-nodes">
                    <?php 
                $first_node_select = "";
                foreach ($this->xmlnodes as $nodekey => $nodecount) {
                    ?>
                        <?php 
                    if ($first_node_select == '') {
                        $first_node_select = $nodecount['key'];
                    }
                    ?>
                        <option value="<?php 
                    echo $nodecount['key'];
                    ?>
">
                            <?php 
                    echo $nodekey . ' (' . $nodecount['count'] . ') ' . $nodecount['key'] . '';
                    ?>
                        </option>
                    <?php 
                }
                ?>
                </select>
                <br / >
                <br / >
                <?php 
                return json_encode(array('select_nodes' => ob_get_clean(), 'selected_element' => $first_node_select, 'response' => 'true'));
                return ob_get_clean();
            } else {
                return json_encode(array('response' => 'false'));
            }
        } elseif ($args['xmlaction'] === 'import') {
            $return_array['node_count'] = count($xml);
            if (count($xml)) {
                foreach ($xml as $key => $value) {
                    Moove_Importer_Controller::moove_recurse_xml($value);
                    $return_array['data'][] = $this->xmlreturn;
                    $this->xmlreturn = array();
                }
            }
            return true;
        } elseif ($args['xmlaction'] === 'preview') {
            $selected_node = $args['node'];
            $xxml = $xml;
            if ($xml->getNamespaces(true)) {
                $xml->registerXpathNamespace('atom', 'http://www.w3.org/2005/Atom');
                $selected_node = str_replace("/", "/atom:", $selected_node);
            }
            $xml = $xml->xpath("{$selected_node}");
            if (count($xml)) {
                ob_start();
                echo "<hr><h4>Node count: " . count($xml) . " <span class='pagination-info'>Current item: 1 / " . count($xml) . " </span></h4>";
                if (count($xml) > 1) {
                    echo "<span data-current='1'>";
                    echo "<a href='#' class='moove-xml-preview-pagination button-previous button-disabled'>Previous</a>";
                    echo "<a href='#' class='moove-xml-preview-pagination button-next'>Next</a>";
                    echo "</span>";
                }
                echo "<hr>";
                $i == 0;
                $return_keys = array();
                $readed_data = array();
                foreach ($xml as $key => $value) {
                    $i++;
                    Moove_Importer_Controller::moove_recurse_xml($value);
                    if ($i > 1) {
                        $hidden_class = 'moove-hidden';
                    } else {
                        $hidden_class = 'moove-active';
                    }
                    echo "<div class='moove-importer-readed-feed {$hidden_class}' data-total='" . count($xml) . "' data-no='{$i}'>";
                    foreach ($this->xmlreturn as $xmlvalue) {
                        $return_keys[] = $xmlvalue['key'];
                        $readed_data[$i]['values'][] = array('key' => $xmlvalue['key'], 'value' => $xmlvalue['value']);
                        ?>
                        <p>
                            <strong>
                                <?php 
                        echo $xmlvalue['key'];
                        ?>
:
                            </strong>
                            <?php 
                        echo $xmlvalue['value'];
                        ?>
                        </p>
                    <?php 
                    }
                    $this->xmlreturn = null;
                    echo "</div>";
                }
                $return_keys = array_unique($return_keys);
                if (count($return_keys)) {
                    $select_options = "<option value='0'>Select a field</option>";
                    $_xml = $xml;
                    foreach ($return_keys as $select_value) {
                        $select_options .= "<option value='" . $select_value . "'>" . $select_value . "</option>";
                    }
                }
                return json_encode(array('content' => ob_get_clean(), 'select_option' => $select_options, 'xml_json_data' => json_encode($readed_data)));
            } else {
                $selected_node = $args['node'];
                $xml = $xxml->xpath("{$selected_node}");
                ob_start();
                echo "<hr><h4>Node count: " . count($xml) . " <span class='pagination-info'>Current item: 1 / " . count($xml) . " </span></h4>";
                if (count($xml) > 1) {
                    echo "<span data-current='1'>";
                    echo "<a href='#' class='moove-xml-preview-pagination button-previous button-disabled'>Previous</a>";
                    echo "<a href='#' class='moove-xml-preview-pagination button-next'>Next</a>";
                    echo "</span>";
                }
                echo "<hr>";
                $i == 0;
                $return_keys = array();
                $readed_data = array();
                foreach ($xml as $key => $value) {
                    $i++;
                    Moove_Importer_Controller::moove_recurse_xml($value);
                    if ($i > 1) {
                        $hidden_class = 'moove-hidden';
                    } else {
                        $hidden_class = 'moove-active';
                    }
                    echo "<div class='moove-importer-readed-feed {$hidden_class}' data-total='" . count($xml) . "' data-no='{$i}'>";
                    foreach ($this->xmlreturn as $xmlvalue) {
                        $return_keys[] = $xmlvalue['key'];
                        $readed_data[$i]['values'][] = array('key' => $xmlvalue['key'], 'value' => $xmlvalue['value']);
                        ?>
                        <p>
                            <strong>
                                <?php 
                        echo $xmlvalue['key'];
                        ?>
:
                            </strong>
                            <?php 
                        echo $xmlvalue['value'];
                        ?>
                        </p>
                    <?php 
                    }
                    $this->xmlreturn = null;
                    echo "</div>";
                }
                $return_keys = array_unique($return_keys);
                if (count($return_keys)) {
                    $select_options = "<option value='0'>Select a field</option>";
                    $_xml = $xml;
                    foreach ($return_keys as $select_value) {
                        $select_options .= "<option value='" . $select_value . "'>" . $select_value . "</option>";
                    }
                }
                return json_encode(array('content' => ob_get_clean(), 'select_option' => $select_options, 'xml_json_data' => json_encode($readed_data)));
            }
        }
    }