none
xmlReader.ReadInnerXml throws xmlexception for invalid hexadecimal characters

    Pertanyaan

  • Hi All,

       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);
                                            xmlReader.MoveToContent();
                                            try
                                            {
                                               AuditXmlOriginal = xmlReader.ReadInnerXml();
                                            }
                                            catch
                                            {
                                            }
                                            xmlReader.Close()

    Thanks,

    AV1810

                                            
    11 Juli 2012 3:18

Semua Balasan