The ':' character, hexadecimal value 0x3A, cannot be included in a name.

السؤال The ':' character, hexadecimal value 0x3A, cannot be included in a name.

  • Wednesday, March 06, 2013 9:09 PM
     
      Has Code

    In my web app, i see an error when doing mail merge,

    The ':' character, hexadecimal value 0x3A, cannot be included in a name.

    Below is the code:

          Public ReadOnly Property XMLNS() As XNamespace
                Get
                    Return XNamespace.[Get](WORDMLNS)
                End Get
            End Property   
            Public Const WORDMLNS As String = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"


    Dim newBody As XElement = XElement.Parse(wordDocument.MainDocumentPart.Document.Body.OuterXml)

                        ' Get all Mail Merge Fields
     Dim mailMergeFields As IList(Of XElement) = (From el In newBody.Descendants() Where el.Attribute(Convert.ToString(XMLNS) & "instr") IsNot Nothing Select el).ToList()

                        ' Replace all merge fields with Data
                        For Each field As XElement In mailMergeFields
                            Dim fieldName As String = field.Attribute(Convert.ToString(XMLNS) & "instr").Value.Replace("MERGEFIELD", String.Empty).Trim().Replace("""", "")
                            If fieldNameList.Contains(fieldName) Then
                                Dim newElement As XElement = field.Descendants(Convert.ToString(XMLNS) & "r").First()
                                newElement.Descendants(Convert.ToString(XMLNS) & "t").First().Value = GetFieldValue(fieldNameList, fieldValueList, fieldName)
                                field.ReplaceWith(newElement)
                            End If
                        Next

    Underlined  throws  the error...

    Can anyone please let me know why it would do that?

    Appreciate the help

    Thanks


    • Edited by My LoginID Wednesday, March 06, 2013 9:10 PM
    •  

All Replies