I have created a Sharepoint list definition, and an instance of that definition. In the instance I need to store some HTML as the value of a field in my list instance. I know I can do this through the UI, but I need this list created on deployment. When I wrap my HTML value in CDATA tags, the item is simply not created. I get a deployment error if I Just have my HTML inline with my XML.
Elements.xml:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="ListName"
OnQuickLaunch="TRUE"
TemplateType="10051"
Url="Lists/ListName"
Description="List Description">
<Data>
<Rows>
<Row>
<Field Name="Title">My Title</Field>
<Field Name="Value">
<p>Some HTML HERE</p>
<table border="1"; cellpadding="10";>
<tr style="font-family:Arial; font-size:10pt;">
<th>header1</th>
<th> ... </th>
</tr>
<tr style="font-family:Arial; font-size:8pt;">
<td>Vaue1</td>
<td> ... </td>
</tr>
</table>
</Field>
</Row>
</Rows>
</Data>
</ListInstance>
</Elements>
Any help would be appreciated.
You need to HTML encode the value:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="ListName"
OnQuickLaunch="TRUE"
TemplateType="10051"
Url="Lists/ListName"
Description="List Description">
<Data>
<Rows>
<Row>
<Field Name="Title">My Title</Field>
<Field Name="Value">
<p>Some HTML HERE</p>
<table border="1"; cellpadding="10";>
<tr style="font-family:Arial; font-size:10pt;">
<th>header1</th>
<th> ... </th>
</tr>
<tr style="font-family:Arial; font-size:8pt;">
<td>Vaue1</td>
<td> ... </td>
</tr>
</table>
</Field>
</Row>
</Rows>
</Data>
</ListInstance>
</Elements>