Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Xml_InvalidCharInThisEncoding

From: "Pierre" <bubble@------.--->
To: 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/



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent