]> git.saurik.com Git - wxWidgets.git/blob - src/xml/xml.cpp
removed obsolete and incorrect comment
[wxWidgets.git] / src / xml / xml.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xml/xml.cpp
3 // Purpose: wxXmlDocument - XML parser & data holder class
4 // Author: Vaclav Slavik
5 // Created: 2000/03/05
6 // RCS-ID: $Id$
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_XML
19
20 #include "wx/xml/xml.h"
21
22 #ifndef WX_PRECOMP
23 #include "wx/intl.h"
24 #include "wx/log.h"
25 #include "wx/app.h"
26 #endif
27
28 #include "wx/wfstream.h"
29 #include "wx/datstrm.h"
30 #include "wx/zstream.h"
31 #include "wx/strconv.h"
32
33 #include "expat.h" // from Expat
34
35 // DLL options compatibility check:
36 WX_CHECK_BUILD_OPTIONS("wxXML")
37
38
39 IMPLEMENT_CLASS(wxXmlDocument, wxObject)
40
41
42
43 //-----------------------------------------------------------------------------
44 // wxXmlNode
45 //-----------------------------------------------------------------------------
46
47 wxXmlNode::wxXmlNode(wxXmlNode *parent,wxXmlNodeType type,
48 const wxString& name, const wxString& content,
49 wxXmlProperty *props, wxXmlNode *next)
50 : m_type(type), m_name(name), m_content(content),
51 m_properties(props), m_parent(parent),
52 m_children(NULL), m_next(next)
53 {
54 if (m_parent)
55 {
56 if (m_parent->m_children)
57 {
58 m_next = m_parent->m_children;
59 m_parent->m_children = this;
60 }
61 else
62 m_parent->m_children = this;
63 }
64 }
65
66 wxXmlNode::wxXmlNode(wxXmlNodeType type, const wxString& name,
67 const wxString& content)
68 : m_type(type), m_name(name), m_content(content),
69 m_properties(NULL), m_parent(NULL),
70 m_children(NULL), m_next(NULL)
71 {}
72
73 wxXmlNode::wxXmlNode(const wxXmlNode& node)
74 {
75 m_next = NULL;
76 m_parent = NULL;
77 DoCopy(node);
78 }
79
80 wxXmlNode::~wxXmlNode()
81 {
82 wxXmlNode *c, *c2;
83 for (c = m_children; c; c = c2)
84 {
85 c2 = c->m_next;
86 delete c;
87 }
88
89 wxXmlProperty *p, *p2;
90 for (p = m_properties; p; p = p2)
91 {
92 p2 = p->GetNext();
93 delete p;
94 }
95 }
96
97 wxXmlNode& wxXmlNode::operator=(const wxXmlNode& node)
98 {
99 wxDELETE(m_properties);
100 wxDELETE(m_children);
101 DoCopy(node);
102 return *this;
103 }
104
105 void wxXmlNode::DoCopy(const wxXmlNode& node)
106 {
107 m_type = node.m_type;
108 m_name = node.m_name;
109 m_content = node.m_content;
110 m_children = NULL;
111
112 wxXmlNode *n = node.m_children;
113 while (n)
114 {
115 AddChild(new wxXmlNode(*n));
116 n = n->GetNext();
117 }
118
119 m_properties = NULL;
120 wxXmlProperty *p = node.m_properties;
121 while (p)
122 {
123 AddProperty(p->GetName(), p->GetValue());
124 p = p->GetNext();
125 }
126 }
127
128 bool wxXmlNode::HasProp(const wxString& propName) const
129 {
130 wxXmlProperty *prop = GetProperties();
131
132 while (prop)
133 {
134 if (prop->GetName() == propName) return true;
135 prop = prop->GetNext();
136 }
137
138 return false;
139 }
140
141 bool wxXmlNode::GetPropVal(const wxString& propName, wxString *value) const
142 {
143 wxXmlProperty *prop = GetProperties();
144
145 while (prop)
146 {
147 if (prop->GetName() == propName)
148 {
149 *value = prop->GetValue();
150 return true;
151 }
152 prop = prop->GetNext();
153 }
154
155 return false;
156 }
157
158 wxString wxXmlNode::GetPropVal(const wxString& propName, const wxString& defaultVal) const
159 {
160 wxString tmp;
161 if (GetPropVal(propName, &tmp))
162 return tmp;
163
164 return defaultVal;
165 }
166
167 void wxXmlNode::AddChild(wxXmlNode *child)
168 {
169 if (m_children == NULL)
170 m_children = child;
171 else
172 {
173 wxXmlNode *ch = m_children;
174 while (ch->m_next) ch = ch->m_next;
175 ch->m_next = child;
176 }
177 child->m_next = NULL;
178 child->m_parent = this;
179 }
180
181 void wxXmlNode::InsertChild(wxXmlNode *child, wxXmlNode *before_node)
182 {
183 wxASSERT_MSG(before_node->GetParent() == this, wxT("wxXmlNode::InsertChild - the node has incorrect parent"));
184
185 if (m_children == before_node)
186 m_children = child;
187 else
188 {
189 wxXmlNode *ch = m_children;
190 while (ch->m_next != before_node) ch = ch->m_next;
191 ch->m_next = child;
192 }
193
194 child->m_parent = this;
195 child->m_next = before_node;
196 }
197
198 bool wxXmlNode::RemoveChild(wxXmlNode *child)
199 {
200 if (m_children == NULL)
201 return false;
202 else if (m_children == child)
203 {
204 m_children = child->m_next;
205 child->m_parent = NULL;
206 child->m_next = NULL;
207 return true;
208 }
209 else
210 {
211 wxXmlNode *ch = m_children;
212 while (ch->m_next)
213 {
214 if (ch->m_next == child)
215 {
216 ch->m_next = child->m_next;
217 child->m_parent = NULL;
218 child->m_next = NULL;
219 return true;
220 }
221 ch = ch->m_next;
222 }
223 return false;
224 }
225 }
226
227 void wxXmlNode::AddProperty(const wxString& name, const wxString& value)
228 {
229 AddProperty(new wxXmlProperty(name, value, NULL));
230 }
231
232 void wxXmlNode::AddProperty(wxXmlProperty *prop)
233 {
234 if (m_properties == NULL)
235 m_properties = prop;
236 else
237 {
238 wxXmlProperty *p = m_properties;
239 while (p->GetNext()) p = p->GetNext();
240 p->SetNext(prop);
241 }
242 }
243
244 bool wxXmlNode::DeleteProperty(const wxString& name)
245 {
246 wxXmlProperty *prop;
247
248 if (m_properties == NULL)
249 return false;
250
251 else if (m_properties->GetName() == name)
252 {
253 prop = m_properties;
254 m_properties = prop->GetNext();
255 prop->SetNext(NULL);
256 delete prop;
257 return true;
258 }
259
260 else
261 {
262 wxXmlProperty *p = m_properties;
263 while (p->GetNext())
264 {
265 if (p->GetNext()->GetName() == name)
266 {
267 prop = p->GetNext();
268 p->SetNext(prop->GetNext());
269 prop->SetNext(NULL);
270 delete prop;
271 return true;
272 }
273 p = p->GetNext();
274 }
275 return false;
276 }
277 }
278
279 wxString wxXmlNode::GetNodeContent() const
280 {
281 wxXmlNode *n = GetChildren();
282
283 while (n)
284 {
285 if (n->GetType() == wxXML_TEXT_NODE ||
286 n->GetType() == wxXML_CDATA_SECTION_NODE)
287 return n->GetContent();
288 n = n->GetNext();
289 }
290 return wxEmptyString;
291 }
292
293
294
295 //-----------------------------------------------------------------------------
296 // wxXmlDocument
297 //-----------------------------------------------------------------------------
298
299 wxXmlDocument::wxXmlDocument()
300 : m_version(wxT("1.0")), m_fileEncoding(wxT("utf-8")), m_root(NULL)
301 {
302 #if !wxUSE_UNICODE
303 m_encoding = wxT("UTF-8");
304 #endif
305 }
306
307 wxXmlDocument::wxXmlDocument(const wxString& filename, const wxString& encoding)
308 :wxObject(), m_root(NULL)
309 {
310 if ( !Load(filename, encoding) )
311 {
312 wxDELETE(m_root);
313 }
314 }
315
316 wxXmlDocument::wxXmlDocument(wxInputStream& stream, const wxString& encoding)
317 :wxObject(), m_root(NULL)
318 {
319 if ( !Load(stream, encoding) )
320 {
321 wxDELETE(m_root);
322 }
323 }
324
325 wxXmlDocument::wxXmlDocument(const wxXmlDocument& doc)
326 :wxObject()
327 {
328 DoCopy(doc);
329 }
330
331 wxXmlDocument& wxXmlDocument::operator=(const wxXmlDocument& doc)
332 {
333 wxDELETE(m_root);
334 DoCopy(doc);
335 return *this;
336 }
337
338 void wxXmlDocument::DoCopy(const wxXmlDocument& doc)
339 {
340 m_version = doc.m_version;
341 #if !wxUSE_UNICODE
342 m_encoding = doc.m_encoding;
343 #endif
344 m_fileEncoding = doc.m_fileEncoding;
345 m_root = new wxXmlNode(*doc.m_root);
346 }
347
348 bool wxXmlDocument::Load(const wxString& filename, const wxString& encoding)
349 {
350 wxFileInputStream stream(filename);
351 if (!stream.Ok())
352 return false;
353 return Load(stream, encoding);
354 }
355
356 bool wxXmlDocument::Save(const wxString& filename) const
357 {
358 wxFileOutputStream stream(filename);
359 if (!stream.Ok())
360 return false;
361 return Save(stream);
362 }
363
364
365
366 //-----------------------------------------------------------------------------
367 // wxXmlDocument loading routines
368 //-----------------------------------------------------------------------------
369
370 /*
371 FIXME:
372 - process all elements, including CDATA
373 */
374
375 // converts Expat-produced string in UTF-8 into wxString using the specified
376 // conv or keep in UTF-8 if conv is NULL
377 static wxString CharToString(wxMBConv *conv,
378 const char *s, size_t len = wxSTRING_MAXLEN)
379 {
380 #if wxUSE_UNICODE
381 wxUnusedVar(conv);
382
383 return wxString(s, wxConvUTF8, len);
384 #else // !wxUSE_UNICODE
385 if ( conv )
386 {
387 // there can be no embedded NULs in this string so we don't need the
388 // output length, it will be NUL-terminated
389 const wxWCharBuffer wbuf(
390 wxConvUTF8.cMB2WC(s, len == wxSTRING_MAXLEN ? wxNO_LEN : len, NULL));
391
392 return wxString(wbuf, *conv);
393 }
394 else // already in UTF-8, no conversion needed
395 {
396 return wxString(s, len != wxSTRING_MAXLEN ? len : strlen(s));
397 }
398 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
399 }
400
401 struct wxXmlParsingContext
402 {
403 wxMBConv *conv;
404 wxXmlNode *root;
405 wxXmlNode *node;
406 wxXmlNode *lastAsText;
407 wxString encoding;
408 wxString version;
409 bool bLastCdata;
410 };
411
412 extern "C" {
413 static void StartElementHnd(void *userData, const char *name, const char **atts)
414 {
415 wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
416 wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, CharToString(ctx->conv, name));
417 const char **a = atts;
418 while (*a)
419 {
420 node->AddProperty(CharToString(ctx->conv, a[0]), CharToString(ctx->conv, a[1]));
421 a += 2;
422 }
423 if (ctx->root == NULL)
424 ctx->root = node;
425 else
426 ctx->node->AddChild(node);
427 ctx->node = node;
428 ctx->lastAsText = NULL;
429 }
430 }
431
432 extern "C" {
433 static void EndElementHnd(void *userData, const char* WXUNUSED(name))
434 {
435 wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
436
437 ctx->node = ctx->node->GetParent();
438 ctx->lastAsText = NULL;
439 }
440 }
441
442 extern "C" {
443 static void TextHnd(void *userData, const char *s, int len)
444 {
445 wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
446 char *buf = new char[len + 1];
447
448 buf[len] = '\0';
449 memcpy(buf, s, (size_t)len);
450
451 if (ctx->lastAsText)
452 {
453 if ( ctx->bLastCdata )
454 {
455 ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() +
456 CharToString(NULL, buf));
457 }
458 else
459 {
460 ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() +
461 CharToString(ctx->conv, buf));
462 }
463 }
464 else
465 {
466 bool whiteOnly = true;
467 for (char *c = buf; *c != '\0'; c++)
468 if (*c != ' ' && *c != '\t' && *c != '\n' && *c != '\r')
469 {
470 whiteOnly = false;
471 break;
472 }
473 if (!whiteOnly)
474 {
475 ctx->lastAsText = new wxXmlNode(wxXML_TEXT_NODE, wxT("text"),
476 CharToString(ctx->conv, buf));
477 ctx->node->AddChild(ctx->lastAsText);
478 }
479 }
480
481 delete[] buf;
482 }
483 }
484
485 extern "C" {
486 static void StartCdataHnd(void *userData)
487 {
488 wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
489
490 ctx->bLastCdata = true;
491
492 ctx->lastAsText = new wxXmlNode(wxXML_CDATA_SECTION_NODE, wxT("cdata"),wxT(""));
493 ctx->node->AddChild(ctx->lastAsText);
494 }
495 }
496
497 extern "C" {
498 static void EndCdataHnd(void *userData)
499 {
500 wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
501
502 ctx->bLastCdata = false;
503 }
504 }
505
506 extern "C" {
507 static void CommentHnd(void *userData, const char *data)
508 {
509 wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
510
511 if (ctx->node)
512 {
513 // VS: ctx->node == NULL happens if there is a comment before
514 // the root element (e.g. wxDesigner's output). We ignore such
515 // comments, no big deal...
516 ctx->node->AddChild(new wxXmlNode(wxXML_COMMENT_NODE,
517 wxT("comment"), CharToString(ctx->conv, data)));
518 }
519 ctx->lastAsText = NULL;
520 }
521 }
522
523 extern "C" {
524 static void DefaultHnd(void *userData, const char *s, int len)
525 {
526 // XML header:
527 if (len > 6 && memcmp(s, "<?xml ", 6) == 0)
528 {
529 wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
530
531 wxString buf = CharToString(ctx->conv, s, (size_t)len);
532 int pos;
533 pos = buf.Find(wxT("encoding="));
534 if (pos != wxNOT_FOUND)
535 ctx->encoding = buf.Mid(pos + 10).BeforeFirst(buf[(size_t)pos+9]);
536 pos = buf.Find(wxT("version="));
537 if (pos != wxNOT_FOUND)
538 ctx->version = buf.Mid(pos + 9).BeforeFirst(buf[(size_t)pos+8]);
539 }
540 }
541 }
542
543 extern "C" {
544 static int UnknownEncodingHnd(void * WXUNUSED(encodingHandlerData),
545 const XML_Char *name, XML_Encoding *info)
546 {
547 // We must build conversion table for expat. The easiest way to do so
548 // is to let wxCSConv convert as string containing all characters to
549 // wide character representation:
550 wxString str(name, wxConvLibc);
551 wxCSConv conv(str);
552 char mbBuf[2];
553 wchar_t wcBuf[10];
554 size_t i;
555
556 mbBuf[1] = 0;
557 info->map[0] = 0;
558 for (i = 0; i < 255; i++)
559 {
560 mbBuf[0] = (char)(i+1);
561 if (conv.MB2WC(wcBuf, mbBuf, 2) == (size_t)-1)
562 {
563 // invalid/undefined byte in the encoding:
564 info->map[i+1] = -1;
565 }
566 info->map[i+1] = (int)wcBuf[0];
567 }
568
569 info->data = NULL;
570 info->convert = NULL;
571 info->release = NULL;
572
573 return 1;
574 }
575 }
576
577 bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding)
578 {
579 #if wxUSE_UNICODE
580 (void)encoding;
581 #else
582 m_encoding = encoding;
583 #endif
584
585 const size_t BUFSIZE = 1024;
586 char buf[BUFSIZE];
587 wxXmlParsingContext ctx;
588 bool done;
589 XML_Parser parser = XML_ParserCreate(NULL);
590
591 ctx.root = ctx.node = NULL;
592 ctx.encoding = wxT("UTF-8"); // default in absence of encoding=""
593 ctx.conv = NULL;
594 #if !wxUSE_UNICODE
595 if ( encoding != wxT("UTF-8") && encoding != wxT("utf-8") )
596 ctx.conv = new wxCSConv(encoding);
597 #endif
598 ctx.bLastCdata = false;
599
600 XML_SetUserData(parser, (void*)&ctx);
601 XML_SetElementHandler(parser, StartElementHnd, EndElementHnd);
602 XML_SetCharacterDataHandler(parser, TextHnd);
603 XML_SetCdataSectionHandler(parser, StartCdataHnd, EndCdataHnd );
604 XML_SetCommentHandler(parser, CommentHnd);
605 XML_SetDefaultHandler(parser, DefaultHnd);
606 XML_SetUnknownEncodingHandler(parser, UnknownEncodingHnd, NULL);
607
608 bool ok = true;
609 do
610 {
611 size_t len = stream.Read(buf, BUFSIZE).LastRead();
612 done = (len < BUFSIZE);
613 if (!XML_Parse(parser, buf, len, done))
614 {
615 wxString error(XML_ErrorString(XML_GetErrorCode(parser)),
616 *wxConvCurrent);
617 wxLogError(_("XML parsing error: '%s' at line %d"),
618 error.c_str(),
619 XML_GetCurrentLineNumber(parser));
620 ok = false;
621 break;
622 }
623 } while (!done);
624
625 if (ok)
626 {
627 if (!ctx.version.empty())
628 SetVersion(ctx.version);
629 if (!ctx.encoding.empty())
630 SetFileEncoding(ctx.encoding);
631 SetRoot(ctx.root);
632 }
633 else
634 {
635 delete ctx.root;
636 }
637
638 XML_ParserFree(parser);
639 #if !wxUSE_UNICODE
640 if ( ctx.conv )
641 delete ctx.conv;
642 #endif
643
644 return ok;
645
646 }
647
648
649
650 //-----------------------------------------------------------------------------
651 // wxXmlDocument saving routines
652 //-----------------------------------------------------------------------------
653
654 // write string to output:
655 inline static void OutputString(wxOutputStream& stream, const wxString& str,
656 wxMBConv *convMem = NULL,
657 wxMBConv *convFile = NULL)
658 {
659 if (str.empty())
660 return;
661
662 #if wxUSE_UNICODE
663 wxUnusedVar(convMem);
664
665 const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
666 stream.Write((const char*)buf, strlen((const char*)buf));
667 #else // !wxUSE_UNICODE
668 if ( convFile && convMem )
669 {
670 wxString str2(str.wc_str(*convMem), *convFile);
671 stream.Write(str2.mb_str(), str2.Len());
672 }
673 else // no conversions to do
674 {
675 stream.Write(str.mb_str(), str.Len());
676 }
677 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
678 }
679
680 // flags for OutputStringEnt()
681 enum
682 {
683 XML_ESCAPE_QUOTES = 1
684 };
685
686 // Same as above, but create entities first.
687 // Translates '<' to "&lt;", '>' to "&gt;" and '&' to "&amp;"
688 static void OutputStringEnt(wxOutputStream& stream, const wxString& str,
689 wxMBConv *convMem = NULL,
690 wxMBConv *convFile = NULL,
691 int flags = 0)
692 {
693 wxString buf;
694 size_t i, last, len;
695 wxChar c;
696
697 len = str.Len();
698 last = 0;
699 for (i = 0; i < len; i++)
700 {
701 c = str.GetChar(i);
702 if (c == wxT('<') || c == wxT('>') ||
703 (c == wxT('&') && str.Mid(i+1, 4) != wxT("amp;")) ||
704 ((flags & XML_ESCAPE_QUOTES) && c == wxT('"')))
705 {
706 OutputString(stream, str.Mid(last, i - last), convMem, convFile);
707 switch (c)
708 {
709 case wxT('<'):
710 OutputString(stream, wxT("&lt;"));
711 break;
712 case wxT('>'):
713 OutputString(stream, wxT("&gt;"));
714 break;
715 case wxT('&'):
716 OutputString(stream, wxT("&amp;"));
717 break;
718 case wxT('"'):
719 OutputString(stream, wxT("&quot;"));
720 break;
721 default:
722 break;
723 }
724 last = i + 1;
725 }
726 }
727 OutputString(stream, str.Mid(last, i - last), convMem, convFile);
728 }
729
730 inline static void OutputIndentation(wxOutputStream& stream, int indent)
731 {
732 wxString str = wxT("\n");
733 for (int i = 0; i < indent; i++)
734 str << wxT(' ') << wxT(' ');
735 OutputString(stream, str);
736 }
737
738 static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent,
739 wxMBConv *convMem, wxMBConv *convFile)
740 {
741 wxXmlNode *n, *prev;
742 wxXmlProperty *prop;
743
744 switch (node->GetType())
745 {
746 case wxXML_CDATA_SECTION_NODE:
747 OutputString( stream, wxT("<![CDATA["));
748 OutputString( stream, node->GetContent() );
749 OutputString( stream, wxT("]]>") );
750 break;
751
752 case wxXML_TEXT_NODE:
753 OutputStringEnt(stream, node->GetContent(), convMem, convFile);
754 break;
755
756 case wxXML_ELEMENT_NODE:
757 OutputString(stream, wxT("<"));
758 OutputString(stream, node->GetName());
759
760 prop = node->GetProperties();
761 while (prop)
762 {
763 OutputString(stream, wxT(" ") + prop->GetName() + wxT("=\""));
764 OutputStringEnt(stream, prop->GetValue(), convMem, convFile,
765 XML_ESCAPE_QUOTES);
766 OutputString(stream, wxT("\""));
767 prop = prop->GetNext();
768 }
769
770 if (node->GetChildren())
771 {
772 OutputString(stream, wxT(">"));
773 prev = NULL;
774 n = node->GetChildren();
775 while (n)
776 {
777 if (n && n->GetType() != wxXML_TEXT_NODE)
778 OutputIndentation(stream, indent + 1);
779 OutputNode(stream, n, indent + 1, convMem, convFile);
780 prev = n;
781 n = n->GetNext();
782 }
783 if (prev && prev->GetType() != wxXML_TEXT_NODE)
784 OutputIndentation(stream, indent);
785 OutputString(stream, wxT("</"));
786 OutputString(stream, node->GetName());
787 OutputString(stream, wxT(">"));
788 }
789 else
790 OutputString(stream, wxT("/>"));
791 break;
792
793 case wxXML_COMMENT_NODE:
794 OutputString(stream, wxT("<!--"));
795 OutputString(stream, node->GetContent(), convMem, convFile);
796 OutputString(stream, wxT("-->"));
797 break;
798
799 default:
800 wxFAIL_MSG(wxT("unsupported node type"));
801 }
802 }
803
804 bool wxXmlDocument::Save(wxOutputStream& stream) const
805 {
806 if ( !IsOk() )
807 return false;
808
809 wxString s;
810
811 wxMBConv *convMem = NULL;
812
813 #if wxUSE_UNICODE
814 wxMBConv *convFile = new wxCSConv(GetFileEncoding());
815 #else
816 wxMBConv *convFile = NULL;
817 if ( GetFileEncoding() != GetEncoding() )
818 {
819 convFile = new wxCSConv(GetFileEncoding());
820 convMem = new wxCSConv(GetEncoding());
821 }
822 #endif
823
824 s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
825 GetVersion().c_str(), GetFileEncoding().c_str());
826 OutputString(stream, s);
827
828 OutputNode(stream, GetRoot(), 0, convMem, convFile);
829 OutputString(stream, wxT("\n"));
830
831 if ( convFile )
832 delete convFile;
833 if ( convMem )
834 delete convMem;
835
836 return true;
837 }
838
839 #endif // wxUSE_XML