Regarding System.XML versus Xerces: Xerces exists to provide a solid, open-source, cross-platform implementation of certain XML standards for C++ developers. Almost all C++ developers are using unmanaged code; I think you're the first I've heard of using Xerces with managed C++.
To the extent that you're in a managed-code environment, Mono's implementation of System.XML may fulfill the same requirements. If you're targeting Windows exclusively, the cross-platform issue is of no consequence; you'll use the Microsoft implementation. My understanding is that System.XML is well-designed and robust, but I can't vouch for that myself. That leaves openness; if that's not important for your project, System.XML would probably be at least as good a fit as Xerces (and I imagine there's a large community of managed code developers who can help you out, though not one of them is as good as Alberto). Using System.XML would avoid redundancy: you wouldn't have to distribute, and your developers wouldn't have to understand, an additional library. This is not to say that you shouldn't use Xerces; it's a great library. Just know your options. -----Original Message----- From: Javier Gálvez Guerrero [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 28, 2007 12:15 PM To: [email protected] Subject: Re: How to parse using DOM Alberto, Thanks again. Everything worked fine. By the way, as I use getNodeValue and getNodeName to process and assign them to my C++ structures I need to parse the XMLCh* returned value to String^ buy I couldn't find any way to do it. Any idea? Jesse, That's a good question..xD. There are many reasons why I am trying to use Xerces in order to parse and create XML files. Maybe you'll find them stupid. Firstly, I am an absolute newbie with C++ as with Xerces (as you have already realized). So, I did no research on XML classes offered by the .NET framework as I didn't know them. Secondly, I am developing an application based on a previous version which was developed by another person, who based his app on Xerces to parse XML files. The problem is that his design didn't take into account creating or writing on XML files, only parsing and reading, so he used the SAX API. Then, I had to switch from SAX to DOM and facing all the problems it implies (creating a NEW app). Thirdly, I thought I could find some help if I based my design on a open source solution like Xerces is, and here it is. Then, if you tell me that it is worth for me working with the System:XML files, then I would think about it..haha. But then, what is Xerces for if everybody can manage their XML files with these classes? Cheers, Javi 2007/11/28, Jesse Pelton <[EMAIL PROTECTED]>: > > Just out of curiosity, if you're using managed code, why aren't you using > the System.XML classes? > > -----Original Message----- > From: Javier Gálvez Guerrero [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 28, 2007 11:03 AM > To: [email protected] > Subject: Re: How to parse using DOM > > Hi there. > > Now I can compile the source code file where I have implemented (or tried > it...) the DOM parser, some errors have appeared. As they seem quite > simple > I hope you could help me again: > > The method in file.cpp is like this (I have followed the guidelines > <http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site, except > for the exception treatment...): > > void contents_manager::load_guide(String^ xml_path){ > > XMLPlatformUtils::Initialize(); > XercesDOMParser* parser = new XercesDOMParser(); > > parser->parse(xml_path); > DOMNode* root = parser->getDocument(); //child_aux1 will be the first > child of root > DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5, > child_aux6, child_aux7; // Compiling errors referring to this line > > //... > > In file.h this is included: > > #include "../include/gincludes.h" > #include "../content/content.h" > #include <xercesc/dom/DOM.hpp> > #include <xercesc/dom/DOMImplementation.hpp> > #include <xercesc/dom/DOMImplementationLS.hpp> > #include <xercesc/dom/DOMWriter.hpp> > #include <xercesc/util/PlatformUtils.hpp> > #include <xercesc/parsers/XercesDOMParser.hpp> > #include <xercesc/dom/DOM.hpp> > #include <xercesc/util/XMLString.hpp> > #include <xercesc/util/PlatformUtils.hpp> > > using namespace System; > > XERCES_CPP_NAMESPACE_USE > > // class definition... > > Then, when compiling a lot of errors appear saying that it can not be done > as I am working with abstracts, referring to the previous red line... > > 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no se > puede crear una instancia de una clase abstract > 1> debido a los siguientes miembros: > 1> 'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const' : > es > abstracto > 1> D:\Ser teleco > > mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246) > : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName' > 1> 'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void) const' : > es > abstracto > 1> D:\Ser teleco > > mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255) > : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue' > 1> 'short xercesc_2_8::DOMNode::getNodeType(void) const' : es > abstracto > ... > > Any idea of what I need to do regarding this error? > > > By the way, as you may have seen on the arguments of my method, the > name/path of the XML file is received with String^ type, so, as I need to > have a char* as an argument for parse->parse(file_name), how can I parse > it? > > Thank you very much, > > Javi > > > > > 2007/11/28, Sven Bauhan <[EMAIL PROTECTED]>: > > > > > This is not true. std::string and UTF-8 are fully compatible, as long > > as > > > you make no assumptions about chopping things up at arbitrary indices, > > or > > > the relationship of Unicode code points and UTF-8 code units. At any > > rate, > > > with a double-byte or multi-byte locale code page, you'd have the same > > > issues. > > > > > I do not really understand what you want to say here. As far as I know > > std::string stores strings in single byte units. In UTF-8 the units have > > variable length between 1 and 4 bytes. So I cannot see a match here. > > I thought to use UTF-8 with the STL you need something like > > std::basic_string<UTFChar>. > > > > Could you tell me, how to transcode the XMLChar* correctly using UTF-8? > > > > Sven > > >
