The Right Format for CDATA inside CDATA

Recently, I would like to include Content Editor webpart into a page through feature. I also would like to initialized my javascript into the CEWP.

Initially, I have my CEWP added to the page manually and edit the webpart source to include my javascript, everything looks good. Export the webpart and include the exported xml into file element in element.xml. I found out there is CDATA tag inside the outer CDATA tag. This makes my outer CDATA tag broken. Its like you need escape characters in a string, if you know what I mean.

I spent a bit of time to look for the solution, probably because I do not search the right keyword in google. Anyway the valid format would be:


<![CDATA[ blah blah blah <![CDATA[ bleh bleh bleh ]]> blah blah blah ]]>


<![CDATA[ blah blah blah <![CDATA[ bleh bleh bleh ]]]]><![CDATA[> blah blah blah ]]>

My full file element would be:

    <File Url="Account.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >
      <Property Name="Title" Value="Account page." />
      <Property Name="UIVersion" Value="4" />
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
      <Property Name="PublishingPreviewImage" Value="$PublishingPreviewImage$" />
      <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomPageLayout.aspx, My Custom Page Layout "/>
      <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_articlepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#"/>
      <AllUsersWebPart WebPartZoneID="Top" WebPartOrder="1">
        <?xml version="1.0" encoding="utf-8"?>
          <WebPart xmlns:xsd="" xmlns:xsi="" xmlns="">
            <Title>Content Editor</Title>
            <Description>Allows authors to enter rich text content.</Description>
            <Height />
            <Width />
            <DetailLink />
            <HelpLink />
            <PartImageSmall />
            <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
            <IsIncludedFilter />
            <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
            <ContentLink xmlns="" />
            <Content xmlns=""><![CDATA[
              function HideAllChildDiv()
          <PartStorage xmlns="" />


Tagged: , , , , ,

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: