0

I have the below field xml which I get after calling a web service. I am getting the error

Name cannot begin with the '=' character, hexadecimal value 0x3D. Line 1, position 2325.

<Field DisplayName='Maximum_x0020_characters_x0020_a' FillInChoice='TRUE' Format ='RadioButtons' Type ='Choice' StaticName ='Maximum_x0020_characters_x0020_a' Required='TRUE' Name='Maximum_x0020_characters_x0020_a'><Default></Default><CHOICES><CHOICE>True</CHOICE><CHOICE>False</CHOICE><CHOICE>True</CHOICE><CHOICE>False</CHOICE><CHOICE>>=255</CHOICE><CHOICE><=255</CHOICE><CHOICE>>=510</CHOICE><CHOICE><= 510</CHOICE></CHOICES></Field> 

Can anyone please suggest the correct way of replacing the special character. I tried replacing &lt and &gt for > and < but then I get another error.

6
  • may be this will help abstractspaces.wordpress.com/2008/05/07/…CommentedJan 11, 2016 at 8:20
  • Can you share the string or display name ? Where is "=" character in it.CommentedJan 11, 2016 at 8:32
  • u can see the xml which i have provided.. the Choice tag have >= as the valueCommentedJan 11, 2016 at 8:35
  • also I tried doing this. but then I get error as Data at the root level is invalid. string _byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()); if (FieldXml.StartsWith(_byteOrderMarkUtf8)) { FieldXml = FieldXml.Remove(0, _byteOrderMarkUtf8.Length); }CommentedJan 11, 2016 at 8:36
  • 1
    I resolved it using <[[CDATA]]>. The XML format containg the special character was binded inside CDATA. IT worked!!!CommentedJan 12, 2016 at 10:00

2 Answers 2

1

I added the special character part in CDATA tag and it worked. For Example I was having the XML of the choice field where choices were coming with special characters which was causing the issue. To overcome it, I added the choice tag of XML in the *** part and it worked.

CDATA takes the value as simple text.

str.Append("<CHOICE><![CDATA[" + choices[k] + "]]></CHOICE>"); 

Choices[k] are my choice value which I am fetching from code.

    0

    If you create a choice column using the browser and enter >=250<=510 etc as choices, and then look at the SchemaXml property of the column (for example using a tool like SharePoint Manager), you can see how they are encoded internally by SharePoint, and help troubleshooting. In this case:

    <CHOICE>&gt;=255</CHOICE> <CHOICE>&lt;=255</CHOICE> <CHOICE>&gt;=510</CHOICE> 

    Perhaps you were missing the semicolon (;) from lt; and gt;.

    CDATA is also a valid option, but for simple cases like these when only a character needs to be encoded, encoding them individually makes the code cleaner.

    1
    • I tried that with semicolon but that was not valid as my choice field was generated dynamically. replacing them with &gt and &lt; was not valid as it was converting the whole xml tag in the format.CommentedJan 13, 2016 at 8:35

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.