Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XmlLite issue - IXmlReader::IsEmptyElement() [Thread Next] Re: XmlLite issue - IXmlReader::IsEmptyElement()To: NULL Date: 2/7/2008 6:06:00 PM
alan.christensen@g... wrote:
> I have another problem with XmlLite losing it's state.
> <TTAG></TTAG>
> I have an XML file where illegal data was entered. (The value of
>  ). Whenever the parser gets to that line it returns S_FALSE
> as a result, and then I can never seem to get it so sync up with
> another line.
>
> How can I handle this error gracefully and not just bail out?
x10 is not an allowed character in XML 1.0 so an XML parser has to
report that as a well-formedness error and stop parsing. I don't think
XmlLite has a setting to change that.
With XmlReader in the .NET framework you can use CheckCharacters on
XmlReaderSettings e.g.
XmlReaderSettings settings = new XmlReaderSettings();
settings.CheckCharacters = false;
string xml = @"<foo></foo>";
using (XmlReader reader = XmlReader.Create(new StringReader(xml),
settings))
{
while (reader.Read())
{
if (reader.HasValue)
{
Console.WriteLine("Value is \"{0}\"", reader.Value);
}
}
}
That way character _references_ to characters outside of the allowed
range are not causing an error but literal characters still do.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
