locked
Invalid Character in XML Comment RRS feed

  • Question

  • Ok, I've read around this issue but havent seen anything online which has helped me, can someone assist?

    I have the following code to read an XML comment. Trouble is the comment has a "degrees" symbol and using the encoding of the file (written by a third party app) the reader rejects it as an invalid character.

    Current encoding is <?xml version="1.0" encoding="UTF-8"?>

    I understand that using the encoding: <?xml version="1.0" encoding="ISO-8859-1"?> resolves the issue, but the third party app writes xml file i'm reading from and updates it every second or so. I'm reading from the file every few seconds. Do I have to re-write the encoding each time or is there an easy way to get around it?

    The code I'm using to read the comment is:

            Dim Reader As XmlReader = XmlReader.Create(String.Concat(dop_dir, dop_file))
    
            Reader.MoveToContent()
    
            While Reader.Read
    
                Select Case Reader.NodeType
                    Case XmlNodeType.Comment
                        Me.txt_dopbear.Text = Reader.Value.Substring(0, 3)
                End Select
    
            End While
    Thanks in advance.

    Tuesday, July 17, 2012 12:48 PM

Answers

  • Update to this - I resolved by using a streamreader instead which has worked.
    • Marked as answer by bigcdh Tuesday, July 17, 2012 3:16 PM
    Tuesday, July 17, 2012 3:16 PM

All replies

  • Update to this - I resolved by using a streamreader instead which has worked.
    • Marked as answer by bigcdh Tuesday, July 17, 2012 3:16 PM
    Tuesday, July 17, 2012 3:16 PM
  • Glad to hear you've solved your problem. Congratulations!

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us

    Friday, July 27, 2012 8:46 AM