Re: Invalid character in XML

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Assuming that the characters are invalid not because of the wrong encoding
(FOR XML results are UTF-16 encoded which means that you need to set it
accordingly on the client side), you have to filter the invalid characters
out in your TSQL code. There may be some non-standard option on the XML
parser that allows you to parse the invalid characters in System.XML, but I
am not sure about that.

Best regards
Michael

"SteveISOA" <SteveISOA@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:385305A5-2C52-4843-A93B-36D209ED13DD@xxxxxxxxxxxxxxxx
> Amol,
>
> At what point can you escape the invalid characters? I do not want to
> modify the existing data in the database, and I'm using a very simple
> process
> of reading and writing the data. It looks something like this:
>
> ...
> SqlCommand mCommand = new SqlCommand(...); //sp with XML EXPLICIT
> ...
> XmlTextWriter txtWriter = new XmlTextWriter(...);
> XmlReader xmlReader = mCommand.ExecuteXmlReader();
>
> while(xmlReader.ReadState != System.Xml.ReadState.EndOfFile)
> {
> txtWriter.WriteNode(xmlReader,false);
> }
> ...
>
> Thanks again.
> Steve
>
> "Amol Kher" wrote:
>
>> Steve,
>>
>> Have you thought about escaping the invalid characters? You can escape
>> using
>> either &<decimal>; or &x<hexadecimal>;
>>
>> Thanks,
>> Amol
>>
>> "SteveISOA" wrote:
>>
>> >
>> > I'm using XML EXPLICIT to query some data which may contain some
>> > invalid XML
>> > characters. While I'm reading in the data I get an error. Other than
>> > removing the characters before the data is inserted into the database,
>> > is
>> > there a way to handle (or omit) reading the invalid characters?
>> >
>> > Thanks.


.



Relevant Pages

  • Re: Internationalization and msxml
    ... Any information on what characters are invalid, ... well-formed and valid xml), ... > Thanks for your Xml document. ...
    (microsoft.public.dotnet.xml)
  • RE: Post Code UK Structure Verification
    ... Dim invalid As Boolean ... ' Validate inner code ..... ... Notepad is used because copying from ... Sort to bring to the top records with too many characters ...
    (microsoft.public.excel.programming)
  • Re: [PHP] One last try at this!
    ... Jim Lucas wrote: ... "Invalid Characters" So $result now contains the value 'Invalid Characters'. ... At one point he mentioned changing ValidateString() to return false on an error. ...
    (php.general)
  • Re: trouble joining exchange 5.5 domain
    ... There might be some old data in AD that references the invalid domain name. ... A SKCC might be required. ... > message when trying to add an exchange 2000 server to the ... > greater than 64 characters or contains at least one of the ...
    (microsoft.public.exchange.misc)
  • Re: mail address validation
    ... [I'm unsure whether the quoting levels are correct. ... what characters are forbidden in "domain" part ... I have read this but regexp on this page return true for user@domain By my opinion this is invalid mail address because TLD ...
    (comp.lang.perl.misc)