3

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()

1 Answer 1

0

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

3
  • Wictor, thank you for your suggestion. It took me some time, but I managed to replace the xmlns attribute in the element string and pass it to my method as a node, but still to no avail. I get the same exception but this time saying 'schemas.microsoft.com/sharepoint' does not contain the ArrayOfProperties element.
    – Tom
    Aug 19, 2011 at 14:31
  • I have corrected the issue by removing the Customization element from the Field node. I have successfully created the field using just the Field element. I plan to iterate throught the ArrayOfProperties and update the newly created TaxonomyFieldType field. If there is a better way to go at this, please let me know. And thank you again for your suggestion.
    – Tom
    Aug 23, 2011 at 14:32
  • The above answer is incorrect, changing the namespace to the mentioned one doesn't fix anything. Also, the OP's note is incorrect too - yes, the field gets created but it will not be fully functional without linking it to a TextField
    – Andrey
    Oct 23, 2013 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.