Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
    
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 '11 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 '11 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 '13 at 19:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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