I get errors when I attempt to compile using VC6 with UNICODE. I searched this forum but cannot resolve the problem. The errors are:
C:\DOCUMENTS AND SETTINGS\PATRICK HARREN\MY DOCUMENTS\VISUAL STUDIO PROJECTS\PugXMLMFC\pugxml.h(1921) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'unsigned short *' (or there is no acceptable conversion)
C:\DOCUMENTS AND SETTINGS\PATRICK HARREN\MY DOCUMENTS\VISUAL STUDIO PROJECTS\PugXMLMFC\pugxml.h(1990) : error C2664: 'bool __thiscall pug::xml_attribute::value(const unsigned short *)' : cannot convert parameter 1 from 'const char *' to 'const unsig
ned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\DOCUMENTS AND SETTINGS\PATRICK HARREN\MY DOCUMENTS\VISUAL STUDIO PROJECTS\PugXMLMFC\pugxml.h(2032) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'const unsigned short *' (or there is no acceptable conver
C:\DOCUMENTS AND SETTINGS\PATRICK HARREN\MY DOCUMENTS\VISUAL STUDIO PROJECTS\PugXMLMFC\pugxml.h(3131) : error C2440: 'default argument' : cannot convert from 'unsigned short ' to 'const class std::basic_string,c
lass std::allocator > &'
Reason: cannot convert from 'unsigned short ' to 'const class std::basic_string,class std::allocator >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\DOCUMENTS AND SETTINGS\PATRICK HARREN\MY DOCUMENTS\VISUAL STUDIO PROJECTS\PugXMLMFC\pugxml.h(3131) : error C2548: 'first_element_by_path' : missing default parameter for parameter 2
I'am exploring this pugXML and I'm very impressed by the job done.
I have a very simple question about attributes:
I would like to delete an attribute named "ID" on every single element (if this attribute is present of course) of my XML file but I don't understand how to use
"attribute_iterator attributes_erase(attribute_iterator where)".
Could anyone help me ?
First I search for xml_node node = xml->document().first_element_by_attribute("package", "id", m_selection);
So I get the child with name "name" (and others if there would be some).
Why the heck does this child not have value Basic now? I realized that I have to use child(0) from this child, but I am still confused that PCDATA is again a child itself and not the value of this first child. Since attribute-values have to be retrieved through attribute("foo") there would have been no problem to use value for the child itself...
Anyhow, as I said I love PugXML, if there would be a STL-style-updated documentation for it. Without something like this looks unusual.
Yes I agree that this is quite confusing. From memory there are cases where the PCDATA/CDATA isn't at child which is why I added xml_node::child_value(), xml_node::find_child() etc. This also explains why the PCDATA/CDATA can't be the nodes value.
It is possible that refactoring the code could improve areas like this, but I've just learnt to live with it.
Perhaps this has been talked a lot but I can not stop my self from writing this.
One of the reasons of XML is connecting platforms, apps through text encoded messages, to achieve this you need compliance. Implementing a fully (95%-98%) compliant XML parser is really hard. Usually an average Dev can get to 80% pretty quickly and the experienced can get to %90. The rest is all egde cases and getting them right requires extensive testing suites to ensure compat between different platforms. I know this by experience. There are quite a few xml parser implementations out there. Users are usually best served when the xml parser implementations are recognized by the W3C Recommendations. Other implementations can not go any further than academic studies as the cost of them making interop with the rest of the world sky rockets as dev's are trying to achieve %95 compat.
On a new xml_node object, setting the value to "" caused an access violation.
Changed the following lines of strcopyinsitu: size_t l = (*dest) ? _tcslen(*dest) : 0; //How long is destination?
if(l >= _tcslen(src)) //Destination is large enough, so just copy.
return TRUE; //Success.
To read: size_t l = (*dest) ? _tcslen(*dest) : 0; //How long is destination?
if(l >= _tcslen(src) && l > 0) //Destination is large enough, so just copy.
return TRUE; //Success.
We just stepped into the same issue. Our fix was slightly different. Instead of:
if (l >= _tcslen(src) && l > 0)
if (l >= _tcslen(src) && *dest)
I think both solutions may work. Basically, you want to protect from writing into a NULL pointer and get into the 'else' part of the 'if' statement.
BTW, we converted this thing to compile using gcc under Linux (embedded BusyBox for XScale/ARM). It took a little doing but it seems to work fine. Most of the changes were Unicode (_T, _tcs...) related and one problem with a method's abiguity. If anybody needs this, sent me a note.
I downloaded the code and attempted to compile it (VC6, Oct2001SDK). I get this kind of compile error:
c:\projects\pug\pugxml.h(1816) : error C2977: '_Ranit' : too many template arguments
c:\program files\microsoft visual studio\vc98\include\utility(77) : see declaration of '_Ranit'
c:\projects\pug\pugxml.h(1844) : see reference to class template instantiation 'pug::xml_iterator<_Ty,_Diff,_Pointer,_Reference>' being compiled
Also, the article makes mention of CPugXmlBranch and lots of wonderful methods to use. However, I can't find this class or anything even with with word 'branch' in it.
#if _MSC_VER < 1300
class xml_iterator : public std::_Ranit<_Ty,_D>
class xml_iterator : public std::_Ranit<_Ty,_Diff,_Pointer,_Reference>
class xml_iterator : public std::random_access_iterator_tag
Int the pugxml.h, the class name are "STL like" named. I think you find what you need in xml_node class.
Now that I read the pugxml.xml file that was supplied, I see that Kristen noted that the MS way of naming (Hungarian notation, CamelCase) was abandoned. That's fine by me as I would also like to use this eventually in an embedded Linux app.
First I would like to thank you for this parser, it really saved me a lot of time. however, when I tried to compile it with Unicode support (wchar_t) i run into some problems. so I have made the following changes, and I will be happy to send them to you if you whish. the changes are: 1. Replaced std:string with basic_string<TCHAR> 2. in load_file the buffer is tested for Unicode text and if it is not text is converted to Unicode - this makes it windows dependent since isTextUnicode is used.