• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Another Visual Basic question - data fails XML parsing

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Another Visual Basic question - data fails XML parsing

    Hi

    Given the success of my previous question about Visual Basic in finding a resolution, I have another issue which I thought I'd share here.

    I have a VB solution written using Visual Studio 2010 which processes an XML file. When the XML data contains an accented character (e.g. í, É, Ó) the program fails with the following message:

    "System.Data.SqlClient.SqlException (0x80131904): XML parsing: line 16, character 23, illegal xml character"

    However, I have another VB solution also written using Visual Studio 2010 which reformats the same data, but that processes the data without any issues.

    I've compared the two solutions and can't see any differences that jump out at me.

    Does anyone have any ideas where I can look to work out why one solution processes the accented data and the other doesn't?

    Thanks in advance.

    #2
    Are you still going through my code - first question is free, second incurs a fee

    Comment


      #3
      Have you tried looking at your xml line 16, character 23?

      Comment


        #4
        Originally posted by Einstein Jnr View Post
        Have you tried looking at your xml line 16, character 23?
        I can't, I'm guessing that's the position in the output file, but because the program crashes it doesn't create the output file so I can't check it. I'm certain it's one of the accented characters.

        Comment


          #5
          This is why I quit programming....

          Comment


            #6
            I'm still waiting to come up on the Premium Bonds. Until then, this is my lot!

            Comment


              #7
              You could always remove the illegal characters.

              Presumably it's some setting to do with character sets. You're meant to specify UTF-8 or whatever in the XML tag.
              Will work inside IR35. Or for food.

              Comment


                #8
                Not enough information.

                It says SqlException, is the data stored as XML in SQL Server, or does it write XML to SQL server and read the data from a file?

                Comment


                  #9
                  Are you explicitly informing whatever does the parsing of what the encoding of the file is? I vaguely remember once having problems with MSXML under some circumstances if I forgot to tell it the input was UTF-8.

                  Comment


                    #10
                    You could always remove the illegal characters.
                    That's an avenue I'm exploring via a REPLACE, but it's up to the client.


                    It says SqlException, is the data stored as XML in SQL Server, or does it write XML to SQL server and read the data from a file?
                    I believe this is what it's doing. I'm not a SQL Server expert, but I think the character set is "SQL_Latin1_General_CP1_CI_AS" - at least that's what I get when I run the command

                    SELECT DATABASEPROPERTYEX('DBName', 'Collation') DatabaseCollation;

                    Is that a character set?


                    Are you explicitly informing whatever does the parsing of what the encoding of the file is? I vaguely remember once having problems with MSXML under some circumstances if I forgot to tell it the input was UTF-8.
                    I'm struggling to find that in the code, but I have found a line that says

                    XmlTextWriter xmlTextWriter = new XmlTextWriter(stream, Encoding.UTF8);

                    so I assume that's where it's defined?

                    Apologies for my woolly answers, but I really am out of my depth.

                    Comment

                    Working...
                    X