Read XML from a HTTP POST

Posted: August 25, 2011 in ColdFusion

I program scripts to read XML posts just every once-and-awhile, and although very simple, every-time I forget how to do it.

Let’s say that we receive a XML HTTP POST via this code:

<cfhttp url="" method="post">
<cfhttpparam type="XML" name="MyXML" value="#myxml#">

This is what you would use to read that POST:

<cfset xmlPOST = GetHTTPRequestData().content>
<cfset xmlDOM = XmlParse(xmlPOST)>

The key here is the GetHTTPRequestData().content. Notice how we do not use form.MyXML.

Now we can manipulate the XML data using standard dot notation such as xmlDOM.Content.Value.XMLText.

  1. Stephen Martin says:


    I was receiving the following error:

    ByteArray objects cannot be converted to strings.

    And it was being thrown by the xmlParse statement:

    I fixed the issue by ensuring that the request was of the type:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s