# Class XmlHttpContent (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.http.xml.XmlHttpContent)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.http.xml.XmlHttpContent)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.xml.XmlHttpContent)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.xml.XmlHttpContent)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.xml.XmlHttpContent)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.xml.XmlHttpContent)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.xml.XmlHttpContent)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.xml.XmlHttpContent)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.xml.XmlHttpContent)

    public class XmlHttpContent extends AbstractXmlHttpContent

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

Serializes XML HTTP content based on the data key/value mapping object for an item.

Sample usage:

static void setContent(HttpRequest request, XmlNamespaceDictionary namespaceDictionary,
String elementName, Object data) {
request.setContent(new XmlHttpContent(namespaceDictionary, elementName, data));
}

Implementation is not thread-safe.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> [AbstractHttpContent](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent) \> [AbstractXmlHttpContent](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.AbstractXmlHttpContent) \> XmlHttpContent

## Inherited Members

[AbstractHttpContent.computeLength()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_computeLength__) [AbstractHttpContent.computeLength(HttpContent)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_computeLength_com_google_api_client_http_HttpContent_) [AbstractHttpContent.getCharset()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_getCharset__) [AbstractHttpContent.getLength()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_getLength__) [AbstractHttpContent.getMediaType()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_getMediaType__) [AbstractHttpContent.getType()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_getType__) [AbstractHttpContent.retrySupported()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.AbstractHttpContent#com_google_api_client_http_AbstractHttpContent_retrySupported__) [AbstractXmlHttpContent.getNamespaceDictionary()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.AbstractXmlHttpContent#com_google_api_client_http_xml_AbstractXmlHttpContent_getNamespaceDictionary__) [AbstractXmlHttpContent.setMediaType(HttpMediaType)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.AbstractXmlHttpContent#com_google_api_client_http_xml_AbstractXmlHttpContent_setMediaType_com_google_api_client_http_HttpMediaType_) [AbstractXmlHttpContent.writeTo(OutputStream)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.AbstractXmlHttpContent#com_google_api_client_http_xml_AbstractXmlHttpContent_writeTo_java_io_OutputStream_) [AbstractXmlHttpContent.writeTo(XmlSerializer)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.AbstractXmlHttpContent#com_google_api_client_http_xml_AbstractXmlHttpContent_writeTo_org_xmlpull_v1_XmlSerializer_) [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-)

## Constructors

### XmlHttpContent(XmlNamespaceDictionary namespaceDictionary, String elementName, Object data)

    public XmlHttpContent(XmlNamespaceDictionary namespaceDictionary, String elementName, Object data)

XML namespace dictionary.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `namespaceDictionary` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.XmlNamespaceDictionary` XML namespace dictionary |
| `elementName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` XML element local name, optionally prefixed by its namespace alias, for example `"atom:entry"` |
| `data` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` Key/value pair data |

## Methods

### getData()

    public final Object getData()

Returns the key/value pair data.

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

### getElementName()

    public final String getElementName()

Returns the XML element local name, optionally prefixed by its namespace alias, for example
`"atom:entry"`.

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

### setMediaType(HttpMediaType mediaType)

    public XmlHttpContent setMediaType(HttpMediaType mediaType)

Sets the media type to use for the Content-Type header, or `null` if unspecified.

This will also overwrite any previously set parameter of the media type (for example `
"charset"`), and therefore might change other properties as well.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `mediaType` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpMediaType` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.XmlHttpContent` |   |

**Overrides** [AbstractXmlHttpContent.setMediaType(HttpMediaType mediaType)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.AbstractXmlHttpContent#com_google_api_client_http_xml_AbstractXmlHttpContent_setMediaType_com_google_api_client_http_HttpMediaType_)

### writeTo(XmlSerializer serializer)

    public final void writeTo(XmlSerializer serializer)

Writes the content to the given XML serializer.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `serializer` | `org.xmlpull.v1.XmlSerializer` |

**Overrides** [AbstractXmlHttpContent.writeTo(XmlSerializer serializer)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.xml.AbstractXmlHttpContent#com_google_api_client_http_xml_AbstractXmlHttpContent_writeTo_org_xmlpull_v1_XmlSerializer_)

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