<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.multipartDecode.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.multipartDecode</api:function-name><api:suggest>xdmp.multipartdecode</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>multipartdecode</api:suggest><api:function-link mode="xquery" fullname="xdmp:multipart-decode">/apidoc/8.0/xdmp:multipart-decode.xml</api:function-link><api:function mode="javascript" name="multipartDecode" type="builtin" lib="xdmp" category="Extension" subcategory="Extension" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.multipartDecode"><api:summary>
  <p xmlns="http://www.w3.org/1999/xhtml">Extract the parts from a multipart encoding. The first item in the
  sequence is a manifest, and the remaining items are the decoded parts.</p>

  <p xmlns="http://www.w3.org/1999/xhtml">An attempt will be made to determine the type of content based on
  headers such as the part's content-type. If possible, an element will be
  returned, falling back to an xs:string, and finally binary().</p>

  <p xmlns="http://www.w3.org/1999/xhtml">The options control how the parts are unpacked, and are similar to
  <a href="./xdmp:zip-get">xdmp:zip-get</a> - default-namespace, repair,
  format, default-language,
  and encoding. The options apply to all parts, so specifying a format of
  binary will cause all parts to be returned as binary, and specifying text
  will cause all parts to be returned as xs:string if possible, falling back
  to binary() if necessary. This is useful if different parts need different
  options, in which case the resulting strings can each be passed to
  xdmp:unquote() with appropriate options.</p>
</api:summary><api:params><api:param name="separator" type="xs:string"><api:param-description>
    The string that is to be used as a separator.
  </api:param-description><api:param-name>separator</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="data" type="binary()"><api:param-description>
    The data (as a binary node) to be decoded.
  </api:param-description><api:param-name>data</api:param-name><api:param-type>binary()</api:param-type></api:param><api:param name="options" type="element()" optional="true"><api:param-description>
    Decode options.
  </api:param-description><api:param-name>options</api:param-name><api:param-type>Node</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:usage>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var html = xdmp.unquote('&lt;html&gt;&lt;p&gt;Some stuff in an .html document&lt;/p&gt;&lt;/html&gt;')
                .next().value;
var xml = xdmp.unquote('&lt;root&gt; \n\
                          &lt;a&gt;Some other stuff in a .xml document&lt;/a&gt; \n\
                        &lt;/root&gt;').next().value;
var json = xdmp.toJSON(["a",false]);
var boundaryString = "gc0p4Jq0M2Yt08jU534c0p";
var manifest = xdmp.unquote(
  '&lt;manifest&gt;'
+   '&lt;part&gt;&lt;headers&gt;'
+     '&lt;Content-Type&gt;application/xml&lt;/Content-Type&gt;'
+     '&lt;boundary&gt;gc0p4Jq0M2Yt08jU534c0p&lt;/boundary&gt;'
+      '&lt;/headers&gt;'
+    '&lt;/part&gt;'
+    '&lt;part&gt;&lt;headers&gt;&lt;Content-Type&gt;text/html&lt;/Content-Type&gt; &lt;/headers&gt;&lt;/part&gt; '
+    '&lt;part&gt;&lt;headers&gt;&lt;Content-Type&gt;application/json&lt;/Content-Type&gt;&lt;/headers&gt;&lt;/part&gt;'
+ '&lt;/manifest&gt;').next().value.root
var mpe = xdmp.multipartEncode(
   boundaryString,
   manifest,
   [xml,html,json] );
xdmp.multipartDecode(boundaryString, mpe);
=&gt;
[
  {
    "headers": {
                 "Content-Type": "application/xml",
                 "boundary": "gc0p4Jq0M2Yt08jU534c0p",
                 "Content-Length": "148"
               }
  },
  {
    "headers": {
                 "Content-Type": "text/html",
                 "Content-Length": "90"
               }
  },
  {
    "headers": {
                 "Content-Type": "application/json",
                 "Content-Length": "12"
               }
  }
]
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;root&gt;&lt;a&gt;Some other stuff in a .xml document&lt;/a&gt;&lt;/root&gt;
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;html&gt;&lt;p&gt;Some stuff in an .html document&lt;/p&gt;&lt;/html&gt;
["a", false]

</pre></api:example></api:function></api:function-page>