An error occurred while parsing EntityName. Line1, position 844

前端 未结 5 1499
星月不相逢
星月不相逢 2020-12-25 10:22

I have got the following exception from the below code block.

An error occurred while parsing EntityName. Line1, position 844.

I was trying

5条回答
  •  眼角桃花
    2020-12-25 10:39

    Just replace them:

    Not valid in XML elements:

    "   "
    '   '
    <   <
    >   >
    &   &
    

      public static string UnescapeXMLValue(string xmlString)
      {
        if (xmlString == null)
            throw new ArgumentNullException("xmlString")
    
        return xmlString.Replace("'", "'").Replace(""", "\"").Replace(">", ">").Replace("<", "<").Replace("&", "&");
      }
    
     public static string EscapeXMLValue(string xmlString)
      {
    
        if (xmlString == null)
            throw new ArgumentNullException("xmlString")
    
        return xmlString.Replace("'","'").Replace( "\"", """).Replace(">",">").Replace( "<","<").Replace( "&","&");
      }
    

提交回复
热议问题