Title: IXR_Value::getXml
Published: July 6, 2022
Last modified: May 20, 2026

---

# IXR_Value::getXml()

[ Back to top](https://developer.wordpress.org/reference/classes/ixr_value/getxml/?output_format=md#wp--skip-link--target)

## Source

    ```php
    function getXml()
    {
        // Return XML for this value
        switch ($this->type) {
            case 'boolean':
                return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
                break;
            case 'int':
                return '<int>'.$this->data.'</int>';
                break;
            case 'double':
                return '<double>'.$this->data.'</double>';
                break;
            case 'string':
                return '<string>'.htmlspecialchars($this->data).'</string>';
                break;
            case 'array':
                $return = '<array><data>'."\n";
                foreach ($this->data as $item) {
                    $return .= '  <value>'.$item->getXml()."</value>\n";
                }
                $return .= '</data></array>';
                return $return;
                break;
            case 'struct':
                $return = '<struct>'."\n";
                foreach ($this->data as $name => $value) {
    	$name = htmlspecialchars($name);
                    $return .= "  <member><name>$name</name><value>";
                    $return .= $value->getXml()."</value></member>\n";
                }
                $return .= '</struct>';
                return $return;
                break;
            case 'date':
            case 'base64':
                return $this->data->getXml();
                break;
        }
        return false;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/ixr/class-ixr-value.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/IXR/class-IXR-value.php#L79)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/IXR/class-IXR-value.php#L79-L119)

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fixr_value%2Fgetxml%2F)
before being able to contribute a note or feedback.