Question

I have successfully recreated all other Column types in SharePoint using the SPFieldCollection.AddFieldAsXml(string xml) method. However, the same method fails for the TaxonomyFieldTypeMulti field type. The reason (possibly) being that the method is not recognizing the element in the parameter xml (Field xml schema).

Listed below are some details. Any help or suggestion as to how to recreate this field type using the provided xml schema would be really helpful.

Field xml schema:

<Field Type="TaxonomyFieldTypeMulti" ... xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <Customization>
    <ArrayOfProperty>
      <Property>
      </Property>
      .
      .
      <Property>
      </Property> 
    </ArrayOfProperty> 
  </Customization>
</Field>

Method used:

AddFieldAsXml Method (String)

Exception thrown:

System.InvalidOperationException: There is an error in XML document (1, 2). ---> System.InvalidOperationException: was not expected. at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderNameValuePairArray.Read3_ArrayOfProperty()

Was it helpful?

Solution

Check your namespace in the Field element. Correct namespace to use is xmlns="http://schemas.microsoft.com/sharepoint/".

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top