Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Xml_InvalidCharInThisEncoding [Thread Next] Re: Xml_InvalidCharInThisEncodingTo: NULL Date: 10/5/2006 1:14:00 AM
Thanks for your quick answer.
I don't know in advance the encoding of the html pages and they're
protected by login so I cannot give the urls. most of them seems to
have been generated from word though.
I managed to find a solution that seems to be working so far:
NameTable m_nt = new NameTable();
XmlNamespaceManager m_nsmgr = new XmlNamespaceManager(m_nt);
nsmgr.AddNamespace("w",
"http://schemas.microsoft.com/office/word/2003/wordml");
XmlParserContext m_context = new XmlParserContext(null, m_nsmgr, null,
XmlSpace.None);
XmlTextReader m_reader=new
XmlTextReader(MyFileManager.StringFromFile(g_path),
XmlNodeType.Element, m_context);
m_reader.Read();
m_XmlDoc.Load(m_reader);
The default encoding in the XmlTextReader seems to be UTF-8, but by
simply using a XmlParserContext it seems to put it on UTF-16. That
solved my problem (so far), but I cannot explain for sure how it works.
Best regards,
Pierre
Martin Honnen wrote:
> Pierre wrote:
>
>
> > I'm trying to load a HTML page into a XPathDocument (or XmlDocument)
> > using C# and .NET 1.1 in order to apply a xsl on it.
>
> HTML is not XML so using XML parsers or APIs to parse HTML fails unless
> the HTML is XHTML.
>
> > Unfortunatly I get this error:
> > ErrorCode "Xml_InvalidCharInThisEncoding" string
> >
> > Example of Html that gives me troubles:
> > <span class="Hyperlink-H" title="8. Value of factor 'X'">8. Value
> > of factor 'X'</span>
>
> Encoding matters for mapping byte sequences to string characters so the
> above does not allow us to say where something goes wrong.
>
> Do you have a URL of the HTML document you are trying to parse? Do you
> know the encoding the HTML has been authored with?
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
