XML (edit)
Vấn đề:
+ Tự tạo tệp XML bằng cách cộng chuỗi
+ Sau đó cần Serialize chuỗi thành Object
+ Lỗi: Cannot Convert XML to C# Object
XmlConvert.EncodeName(title);
Giải pháp:
You can use HttpUtility.HtmlEncode + HttpUtility.HtmlDecode or with .NET 4.0+ you can also use WebUtility.HtmlEncode + WebUtility.HtmlDecode
- Namespace:
- System.Xml
- Assembly:
- System.Xml.ReaderWriter.dll
XmlConvert.EncodeName(title);
Refer
https://www.c-sharpcorner.com/UploadFile/mahesh/verify-xml-names-using-C-Sharp/
https://gist.github.com/jipengxiang/8611e4bf390bbf18ccc9
https://stackoverflow.com/questions/22906722/how-to-encode-special-characters-in-xml
https://stackoverflow.com/questions/8331119/escape-invalid-xml-characters-in-c-sharp
https://www.codeproject.com/Articles/1163664/Convert-XML-to-Csharp-Object
https://stackoverflow.com/questions/11447529/convert-an-object-to-an-xml-string