# Class Xml (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.Xml)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.xml.Xml)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.xml.Xml)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.xml.Xml)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.xml.Xml)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.xml.Xml)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.xml.Xml)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.xml.Xml)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.xml.Xml)

    public class Xml

[Beta](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Beta)   

XML utilities.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> Xml

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Fields

### MEDIA_TYPE

    public static final String MEDIA_TYPE

`"application/xml; charset=utf-8"` media type used as a default for XML parsing.

Use [HttpMediaType#equalsIgnoreParameters](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpMediaType#com_google_api_client_http_HttpMediaType_equalsIgnoreParameters_) for comparing media types.

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Static Methods

### createParser()

    public static XmlPullParser createParser()

Returns a new XML pull parser.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.xmlpull.v1.XmlPullParser` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `org.xmlpull.v1.XmlPullParserException` |   |

### createSerializer()

    public static XmlSerializer createSerializer()

Returns a new XML serializer.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.xmlpull.v1.XmlSerializer` |   |

### parseElement(XmlPullParser parser, Object destination, XmlNamespaceDictionary namespaceDictionary, Xml.CustomizeParser customizeParser)

    public static void parseElement(XmlPullParser parser, Object destination, XmlNamespaceDictionary namespaceDictionary, Xml.CustomizeParser customizeParser)

Parses an XML element using the given XML pull parser into the given destination object.

Requires the current event be XmlPullParser#START_TAG (skipping any initial XmlPullParser#START_DOCUMENT) of the element being parsed. At normal parsing completion, the
current event will either be XmlPullParser#END_TAG of the element being parsed, or the
XmlPullParser#START_TAG of the requested `atom:entry`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parser` | `org.xmlpull.v1.XmlPullParser` XML pull parser |
| `destination` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` optional destination object to parser into or `null` to ignore XML content |
| `namespaceDictionary` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.XmlNamespaceDictionary` XML namespace dictionary to store unknown namespaces |
| `customizeParser` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.Xml.CustomizeParser` optional parser customizer or `null` for none |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `org.xmlpull.v1.XmlPullParserException` |   |

### toStringOf(Object element)

    public static String toStringOf(Object element)

Shows a debug string representation of an element data object of key/value pairs.

It will make up something for the element name and XML namespaces. If those are known, it is
better to use [XmlNamespaceDictionary#toStringOf(String, Object)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.XmlNamespaceDictionary#com_google_api_client_xml_XmlNamespaceDictionary_toStringOf_java_lang_String_java_lang_Object_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `element` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` element data object of key/value pairs ([GenericXml](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.GenericXml), [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html), or any object with public fields) |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |