Re: Invalid character in XML
- From: "Michael Rys [MSFT]" <mrys@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 12:28:20 -0700
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.
.
- Prev by Date: Re: How to generate Auto number for records inserted using Openxml
- Next by Date: Re: Bug using FOR XML AUTO with columns with type char(1)
- Previous by thread: Re: Invalid character in XML
- Next by thread: Re: How to import a XSD and XML file into a SQL table
- Index(es):
Relevant Pages
|