I have a xml file that holds metadata properties info of an listitem in a library. The metadata properties holds some invalid hexadecimal characters. I use the below code to read the xml file, it throws invalid hexadecimal characters xml exception.
CharacterSettings - checkcharacter doesnt seem to work. can anyone help me on how to handle this exception to remove those invalid xml values:
SpFile ItemAuditFile = ListItem.File ;\\xml file with info on properties
Stream AuditFile = ItemAuditFile.OpenBinaryStream();
var charSettings = new XmlReaderSettings()
CheckCharacters = false
XmlReader xmlReader = XmlReader.Create(AuditFile , charSettings);
AuditXmlOriginal = xmlReader.ReadInnerXml();
You can use following code the remove the invalid character
Hope this will work.
Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.
The above references explains as how to validate a string. But the code throws the invalid value exception While trying to read the xml file to convert as a string on line - xmlReader.ReadInnerXml();
Sorry am not aware of it. Can you let me know as how to implement it in the above code.