A few days ago, a program that parsing XML is required in the program, so I started learning. Previously, Java-based Xerces based on Apache was previously used on the Solaris platform. It should be not a problem. This time is developed on Windows, so I am ready to use MSXML. First, I downloaded a MSXML SDK 4.0 SP2 at www.microsoft.com. After installation, I followed a SAX2 program (Visual C Win32 Console program) in accordance with the help file, run successfully. Then I started reading my own XML file, dumbful, Chinese attribute can't read it! Tracking the contentHandler of SAX2, reading the character length of the character's getValue is 2, just a "good! First, I think it may be an encoding problem, use XMLSPY 2005 to adjust Encoding to GB2312, UTF-8, UTF- 16, UCS-2, etc., don't! Then, I will change the project to Unicode compilation, nor! The province's MBCS will not work. The third step, the Microsoft China website, a msxmlchs.msi Chinese version, installation , The problem is still! The fourth step, download Xerces C, compile SAX2PRINT in Examples, can read Chinese, but need a conversion class, feeling and MFC combination is not very good (maybe I am not familiar with Xerces C), although Step 5, use the DOM model, or you can't read Chinese! Sixth, use Smart Pointer DOM, I can finally read Chinese, but I still want to find DOM and SAX2 why can't read Chinese. Finally Some information, finally finding the reason, to call setLocale (lc_all, "Chinese-simplified"). It seems that the C language does not have time. There is not so much trouble in the MFC application, you can use it directly
Author Blog:
http://blog.9cbs.net/zei709/