Ticket #13297 (closed defect: wontfix)
wxXmlDocument save (OutputNode) does not output wxXML_ELEMENT_NODE content
|Reported by:||chief||Owned by:|
And especially Vadim who helped me a few (6 or 7 ?) years ago with (my) problems with wxSockets.
Hopefully this pays some of that back – firstly platform and version specifications.
WX : 2.8.11 AND 2.9.1
OS : Windows XP (SP3) AND Windows 7
COMPILER: VC9 IDE
The above is (I think) not relevant to this particular issue from what I have seen of the code, but deadlines prevent me from a full investigation.
I have some code which does something like the following (pScenarioNode is a wxXMLNode*):
lastNode = nextNode;
pScenarioNode->InsertChildAfter((nextNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("BusinessUnit"), pScenario->GetBusinessUnit())),lastNode);
lastNode = nextNode;
pScenarioNode->InsertChildAfter((nextNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("Location"), pScenario->GetLocation())),lastNode);
This creates (or should create) an XML fragment which appears as follows:
<BusinessUnit>Some Business Unit</BusinessUnit>
I couldn’t get this to generate the expected output in a file when calling wxXmlDocument.Save() – I got the XML structure but not the content.
I think (from memory), version 2.8.11 gave me little more than the version and encoding information.
I tracked this down eventually, and made some changes to xml.cpp which fixd the issue (at least for me), but forgot about it until I moved to version 2.9.1 when I was getting all the elements, but no content.
The above XML fragement, effectively appeared as follows:
It would appear that the OutputNode() function was not outputting an XMLNode’s content.
Attached is the modified file (xml.cpp zipped using winzip) that I am now using (from the 2.9.1 release), which is far from perfect, but suits my needs and I think solves the issue in some way that may warrant inclusion in a future release.
I added a #ifdef so I could output empty elements as either:
Personally, I would like to see it in an OutputElementNode() function which outputs everything an element can encapsulate.
The changes are confined to a section which starts and ends with // ACF (i.e. search for this)
A final question.
What is the future of wxXML ? I think I read somewhere it will be dropped in a future release – is this the case ?
Will it be replaced by something else or simply go missing ?
I have previously used Xerces in conjunction with wxWidgets but would like to plan for this sooner rather than later if it is inevitable, especially considering how complex Xerces has become since 3.x
Thanks for all the hard work and a fantastic library from a user of almost 10 years.