MSXML in C++ but as elegant as in C# (Part 6)

יום שבת, דצמבר 27, 2008

OK, this is the last post on the subject. You can find the first post here and the previous one here. In this post, I want to show you how the tips and tricks we have been discussing make our C++ code quite elegant for the three projects we haven’t reviewed yet: XMLBuilder, XSDValidator and XSLTTransformer. As usual, my benchmark for elegance is a comparison with equivalent C# code, however in the last two projects, the code is not identical in the two languages due to differences in the COM and System.Xml APIs for validation and transformation....
תגיות: ,
8 תגובות

MSXML in C++ but as elegant as in C# (Part 5)

יום שישי, דצמבר 26, 2008

Part 1 is the first post in this series. In Part 4 I described the first of the 5 project pairs provided with this article, DOMAndXPath. In this post I will review the second project – SAXReader. The SAX programming model is very different to the DOM model: SAX models the parser, whereas DOM models the XML document. SAX provides a forward only push model, where as DOM provides random access to nodes in the document. The SAXReader project is based on the MSDN example you can find here. It defines a content handler, attaches it...
תגיות: ,
אין תגובות

MSXML in C++ but as elegant as in C# (Part 4)

יום חמישי, דצמבר 25, 2008

Part 1 is the first post in this series. In Part 3 I described 3 simple steps that will help simplify your MSXML enabled C++ project. With those in place we are ready to examine each of the 5 project pairs provided with this article in more detail. Each project demonstrates how to implement a set of basic XML functions using MSXML in C++. In this post I will review the first of the five - DOMAndXPath. This project loads an XML file into a DOM, recursively traverses its nodes and displays them. It then displays a...
תגיות: ,
2 תגובות

MSXML in C++ but as elegant as in C# (Part 3)

יום רביעי, דצמבר 24, 2008

See the previous posts for this article here: Part 1, Part 2. Before I review the projects for this article, I would like to describe the basics: a few simple steps that will give you a C# experience while programming MSXML with C++. Step 1: Import MSXML There are a number of ways to import com libraries in a C++ project. I think the simplest way is to add the following line in a common header (best precompiled). #import <msxml6.dll> named_guids This will create the headers (with extensions .tli and...
תגיות: ,
18 תגובות

MSXML in C++ but as elegant as in C# (Part 2)

יום שני, דצמבר 22, 2008

So, in my opening post on this subject (Part 1), I promised to show you some useful sample code using MSXML, written in C++ yet as elegant as C#. Well. Here is an example of what can be achieved. C++ C# ...
תגיות: ,
אין תגובות

MSXML in C++ but as elegant as in C# (Part 1)

יום שבת, דצמבר 20, 2008

Well, I did say that I would change subjects from time to time : ) This week I taught a class of C++ Programmers how to use MSXML and I sat down to write samples and demos for the lesson. Well, I love C++, but C# has spoiled me. Programming COM directly can get ugly and working with MSXML in C++ is no exception: all those AddRefs and Releases you need to call, HRESULTS you need to handle, and CLSIDs you need to find. Code that accesses COM directly is often error prone,...
תגיות: ,
3 תגובות