Contents Up Previous Next

wxXmlDocument

This class holds XML data/document as parsed by XML parser in the root node.

wxXmlDocument internally uses the expat library which comes with wxWidgets to parse the given stream.

Derived from

wxObject

Include files

<wx/xml/xml.h>

See also

wxXmlNode, wxXmlProperty

Members

wxXmlDocument::wxXmlDocument
wxXmlDocument::~wxXmlDocument
wxXmlDocument::GetEncoding
wxXmlDocument::GetFileEncoding
wxXmlDocument::GetRoot
wxXmlDocument::GetVersion
wxXmlDocument::IsOk
wxXmlDocument::Load
wxXmlDocument::Save
wxXmlDocument::SetEncoding
wxXmlDocument::SetFileEncoding
wxXmlDocument::SetRoot
wxXmlDocument::SetVersion
wxXmlDocument::operator=


wxXmlDocument::wxXmlDocument

wxXmlDocument()

wxXmlDocument(const wxString& filename, const wxString& encoding = wxT("UTF-8"))

Loads the given filename using the given encoding. See Load().

wxXmlDocument(wxInputStream& stream, const wxString& encoding = wxT("UTF-8"))

Loads the XML document from given stream using the given encoding. See Load().

wxXmlDocument(const wxXmlDocument& doc)

Copy constructor.


wxXmlDocument::~wxXmlDocument

~wxXmlDocument()

Virtual destructor. Frees the document root node.


wxXmlDocument::GetEncoding

wxString GetEncoding() const

Returns encoding of in-memory representation of the document (same as passed to Load() or constructor, defaults to UTF-8).

NB: this is meaningless in Unicode build where data are stored as wchar_t*.


wxXmlDocument::GetFileEncoding

wxString GetFileEncoding() const

Returns encoding of document (may be empty).

Note: this is the encoding original file was saved in, *not* the encoding of in-memory representation!


wxXmlDocument::GetRoot

wxXmlNode* GetRoot() const

Returns the root node of the document.


wxXmlDocument::GetVersion

wxString GetVersion() const

Returns the version of document. This is the value in the <?xml version="1.0"?> header of the XML document. If the version property was not explicitely given in the header, this function returns an empty string.


wxXmlDocument::IsOk

bool IsOk() const

Returns true if the document has been loaded successfully.


wxXmlDocument::Load

bool Load(const wxString& filename, const wxString& encoding = wxT("UTF-8"))

Parses filename as an xml document and loads data. Returns true on success, false otherwise.

bool Load(wxInputStream& stream, const wxString& encoding = wxT("UTF-8"))

Like above but takes the data from given input stream.


wxXmlDocument::Save

bool Save(const wxString& filename) const

Saves XML tree creating a file named with given string.

bool Save(wxOutputStream& stream) const

Saves XML tree in the given output stream.


wxXmlDocument::SetEncoding

void SetEncoding(const wxString& enc)

Sets the enconding of the document.


wxXmlDocument::SetFileEncoding

void SetFileEncoding(const wxString& encoding)

Sets the enconding of the file which will be used to save the document.


wxXmlDocument::SetRoot

void SetRoot(wxXmlNode* node)

Sets the root node of this document. Deletes previous root node.


wxXmlDocument::SetVersion

void SetVersion(const wxString& version)

Sets the version of the XML file which will be used to save the document.


wxXmlDocument::operator=

wxXmlDocument& operator operator=(const wxXmlDocument& doc)

Copies the given document.