Panda3D
Public Member Functions | List of all members
TiXmlDocument Class Reference

Always the top level node. More...

Inheritance diagram for TiXmlDocument:
TiXmlNode TiXmlBase

Public Member Functions

 __init__ ()
 Create an empty document, that has no name. More...
 
 __init__ (const TiXmlDocument copy)
 
 __init__ (str documentName)
 Create a document with a name. The name of the document is also the filename of the xml. More...
 
 __init__ (str documentName)
 Constructor. More...
 
 ClearError ()
 If you have handled the error, it can be reset with this call. More...
 
bool Error ()
 If an error occurs, Error will be set to true. More...
 
int ErrorCol ()
 
str ErrorDesc ()
 Contains a textual (english) description of the error if one occurs. More...
 
int ErrorId ()
 Generally, you probably want the error string ( ErrorDesc() ). More...
 
int ErrorRow ()
 Returns the location (if known) of the error. More...
 
bool LoadFile (FILE, TiXmlEncoding encoding)
 Load a file using the given FILE*. More...
 
bool LoadFile (TiXmlEncoding encoding)
 Load a file using the current document value. More...
 
bool LoadFile (str filename, TiXmlEncoding encoding)
 Load a file using the given filename. Returns true if successful. More...
 
bool LoadFile (str filename, TiXmlEncoding encoding)
 
TiXmlDocument operator= (const TiXmlDocument copy)
 
 Print ()
 Write the document to standard out using formatted printing ("pretty print"). More...
 
TiXmlElement RootElement ()
 
const TiXmlElement RootElement ()
 Get the root element – the only top level element – of the document. More...
 
bool SaveFile ()
 Save a file using the current document value. Returns true if successful. More...
 
bool SaveFile (FILE)
 Save a file using the given FILE*. Returns true if successful. More...
 
bool SaveFile (str filename)
 Save a file using the given filename. Returns true if successful. More...
 
bool SaveFile (str filename)
 
 SetError (int err, str errorLocation, TiXmlParsingData prevData, TiXmlEncoding encoding)
 
 SetTabSize (int _tabsize)
 SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column. More...
 
int TabSize ()
 
- Public Member Functions inherited from TiXmlNode
bool Accept (TiXmlVisitor visitor)
 Accept a hierchical visit the nodes in the TinyXML DOM. More...
 
 Clear ()
 Delete all the children of this node. Does not affect 'this'. More...
 
TiXmlNode Clone ()
 Create an exact duplicate of this node and return it. More...
 
TiXmlNode FirstChild ()
 The first child of this node. Will be null if there are no children. More...
 
const TiXmlNode FirstChild ()
 The first child of this node with the matching 'value'. Will be null if none found. The first child of this node with the matching 'value'. Will be null if none found. More...
 
TiXmlNode FirstChild (str _value)
 
const TiXmlNode FirstChild (str value)
 STL std::string form. More...
 
TiXmlNode FirstChild (str _value)
 STL std::string form. More...
 
const TiXmlNode FirstChild (str _value)
 
TiXmlElement FirstChildElement ()
 
const TiXmlElement FirstChildElement ()
 Convenience function to get through elements. More...
 
TiXmlElement FirstChildElement (str _value)
 
const TiXmlElement FirstChildElement (str _value)
 Convenience function to get through elements. More...
 
TiXmlElement FirstChildElement (str _value)
 STL std::string form. More...
 
const TiXmlElement FirstChildElement (str _value)
 
TiXmlDocument GetDocument ()
 
const TiXmlDocument GetDocument ()
 Return a pointer to the Document this node lives in. More...
 
TiXmlNode InsertAfterChild (TiXmlNode afterThis, const TiXmlNode addThis)
 Add a new node related to this. More...
 
TiXmlNode InsertBeforeChild (TiXmlNode beforeThis, const TiXmlNode addThis)
 Add a new node related to this. More...
 
TiXmlNode InsertEndChild (const TiXmlNode addThis)
 Add a new node related to this. More...
 
TiXmlNode IterateChildren (const TiXmlNode previous)
 
const TiXmlNode IterateChildren (const TiXmlNode previous)
 An alternate way to walk the children of a node. More...
 
TiXmlNode IterateChildren (str _value, const TiXmlNode previous)
 
const TiXmlNode IterateChildren (str value, const TiXmlNode previous)
 This flavor of IterateChildren searches for children with a particular 'value'. More...
 
TiXmlNode IterateChildren (str _value, const TiXmlNode previous)
 STL std::string form. More...
 
const TiXmlNode IterateChildren (str _value, const TiXmlNode previous)
 
TiXmlNode LastChild ()
 The last child of this node. Will be null if there are no children. More...
 
const TiXmlNode LastChild ()
 The last child of this node. Will be null if there are no children. More...
 
TiXmlNode LastChild (str _value)
 The last child of this node matching 'value'. Will be null if there are no children. More...
 
const TiXmlNode LastChild (str value)
 The last child of this node matching 'value'. Will be null if there are no children. More...
 
TiXmlNode LastChild (str _value)
 STL std::string form. More...
 
const TiXmlNode LastChild (str _value)
 
TiXmlNode NextSibling ()
 
const TiXmlNode NextSibling ()
 Navigate to a sibling node. More...
 
TiXmlNode NextSibling (str _next)
 
const TiXmlNode NextSibling (str)
 Navigate to a sibling node with the given 'value'. More...
 
TiXmlNode NextSibling (str _value)
 STL std::string form. More...
 
const TiXmlNode NextSibling (str _value)
 
TiXmlElement NextSiblingElement ()
 
const TiXmlElement NextSiblingElement ()
 Convenience function to get through elements. More...
 
TiXmlElement NextSiblingElement (str _next)
 
const TiXmlElement NextSiblingElement (str)
 Convenience function to get through elements. More...
 
TiXmlElement NextSiblingElement (str _value)
 STL std::string form. More...
 
const TiXmlElement NextSiblingElement (str _value)
 
bool NoChildren ()
 Returns true if this node has no children. More...
 
TiXmlNode Parent ()
 One step up the DOM. More...
 
const TiXmlNode Parent ()
 The first child of this node. Will be null if there are no children. More...
 
TiXmlNode PreviousSibling ()
 
const TiXmlNode PreviousSibling ()
 Navigate to a sibling node. More...
 
TiXmlNode PreviousSibling (str _prev)
 
const TiXmlNode PreviousSibling (str)
 Navigate to a sibling node. More...
 
TiXmlNode PreviousSibling (str _value)
 STL std::string form. More...
 
const TiXmlNode PreviousSibling (str _value)
 
bool RemoveChild (TiXmlNode removeThis)
 Delete a child of this node. More...
 
TiXmlNode ReplaceChild (TiXmlNode replaceThis, const TiXmlNode withThis)
 Replace a child of this node. More...
 
 SetValue (str _value)
 Changes the value of the node. More...
 
 SetValue (str _value)
 STL std::string form. More...
 
TiXmlComment ToComment ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlComment ToComment ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlDeclaration ToDeclaration ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlDeclaration ToDeclaration ()
 
TiXmlDocument ToDocument ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlDocument ToDocument ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlElement ToElement ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlElement ToElement ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlText ToText ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlText ToText ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlUnknown ToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlUnknown ToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
int Type ()
 Query the type (as an enumerated value, above) of this node. More...
 
str Value ()
 The meaning of 'value' changes for the specific type of TiXmlNode. More...
 
str ValueStr ()
 Return Value() as a std::string. More...
 
str ValueTStr ()
 
- Public Member Functions inherited from TiXmlBase
int Column ()
 Get a pointer to arbitrary user data. More...
 
 GetUserData ()
 Get a pointer to arbitrary user data. More...
 
 GetUserData ()
 
str Parse (str p, TiXmlParsingData data, TiXmlEncoding encoding)
 
 Print (FILE cfile, int depth)
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.) Either or both cfile and str can be null. More...
 
int Row ()
 Return the position, in the original source file, of this node or attribute. More...
 

Additional Inherited Members

- Public Types inherited from TiXmlNode
enum  NodeType {
  TINYXML_DOCUMENT = 0, TINYXML_ELEMENT = 1, TINYXML_COMMENT = 2, TINYXML_UNKNOWN = 3,
  TINYXML_TEXT = 4, TINYXML_DECLARATION = 5, TINYXML_TYPECOUNT = 6
}
 The types of XML nodes supported by TinyXml. More...
 
- Public Types inherited from TiXmlBase
enum  {
  TIXML_NO_ERROR = 0, TIXML_ERROR = 1, TIXML_ERROR_OPENING_FILE = 2, TIXML_ERROR_PARSING_ELEMENT = 3,
  TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME = 4, TIXML_ERROR_READING_ELEMENT_VALUE = 5, TIXML_ERROR_READING_ATTRIBUTES = 6, TIXML_ERROR_PARSING_EMPTY = 7,
  TIXML_ERROR_READING_END_TAG = 8, TIXML_ERROR_PARSING_UNKNOWN = 9, TIXML_ERROR_PARSING_COMMENT = 10, TIXML_ERROR_PARSING_DECLARATION = 11,
  TIXML_ERROR_DOCUMENT_EMPTY = 12, TIXML_ERROR_EMBEDDED_NULL = 13, TIXML_ERROR_PARSING_CDATA = 14, TIXML_ERROR_DOCUMENT_TOP_ONLY = 15,
  TIXML_ERROR_STRING_COUNT = 16
}
 
- Static Public Member Functions inherited from TiXmlBase
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting. More...
 
static SetCondenseWhiteSpace (bool condense)
 The world does not agree on whether white space should be kept or not. More...
 

Detailed Description

Always the top level node.

A document binds together all the XML pieces. It can be saved, loaded, and printed to the screen. The 'value' of a document node is the xml file name.

Member Function Documentation

◆ __init__() [1/4]

__init__ ( )

Create an empty document, that has no name.

◆ __init__() [2/4]

__init__ ( const TiXmlDocument  copy)

◆ __init__() [3/4]

__init__ ( str  documentName)

Create a document with a name. The name of the document is also the filename of the xml.

◆ __init__() [4/4]

__init__ ( str  documentName)

Constructor.

◆ ClearError()

ClearError ( )

If you have handled the error, it can be reset with this call.

The error state is automatically cleared if you Parse a new XML block.

◆ Error()

bool Error ( )

If an error occurs, Error will be set to true.

Also,

  • The ErrorId() will contain the integer identifier of the error (not generally useful)
  • The ErrorDesc() method will return the name of the error. (very useful)
  • The ErrorRow() and ErrorCol() will return the location of the error (if known)

◆ ErrorCol()

int ErrorCol ( )

◆ ErrorDesc()

str ErrorDesc ( )

Contains a textual (english) description of the error if one occurs.

◆ ErrorId()

int ErrorId ( )

Generally, you probably want the error string ( ErrorDesc() ).

But if you prefer the ErrorId, this function will fetch it.

◆ ErrorRow()

int ErrorRow ( )

Returns the location (if known) of the error.

The first column is column 1, and the first row is row 1. A value of 0 means the row and column wasn't applicable (memory errors, for example, have no row/column) or the parser lost the error. (An error in the error reporting, in that case.)

See also
SetTabSize, Row, ColumnThe column where the error occured. See ErrorRow()

◆ LoadFile() [1/4]

bool LoadFile ( FILE  ,
TiXmlEncoding  encoding 
)

Load a file using the given FILE*.

Returns true if successful. Note that this method doesn't stream - the entire object pointed at by the FILE* will be interpreted as an XML file. TinyXML doesn't stream in XML from the current file location. Streaming may be added in the future.

◆ LoadFile() [2/4]

bool LoadFile ( TiXmlEncoding  encoding)

Load a file using the current document value.

Returns true if successful. Will delete any existing document data before loading.

◆ LoadFile() [3/4]

bool LoadFile ( str  filename,
TiXmlEncoding  encoding 
)

Load a file using the given filename. Returns true if successful.

STL std::string version.

◆ LoadFile() [4/4]

bool LoadFile ( str  filename,
TiXmlEncoding  encoding 
)

◆ operator=()

TiXmlDocument operator= ( const TiXmlDocument  copy)

◆ Print()

Print ( )

Write the document to standard out using formatted printing ("pretty print").

◆ RootElement() [1/2]

TiXmlElement RootElement ( )

◆ RootElement() [2/2]

const TiXmlElement RootElement ( )

Get the root element – the only top level element – of the document.

In well formed XML, there should only be one. TinyXml is tolerant of multiple elements at the document level.

◆ SaveFile() [1/4]

bool SaveFile ( )

Save a file using the current document value. Returns true if successful.

◆ SaveFile() [2/4]

bool SaveFile ( FILE  )

Save a file using the given FILE*. Returns true if successful.

◆ SaveFile() [3/4]

bool SaveFile ( str  filename)

Save a file using the given filename. Returns true if successful.

STL std::string version.

◆ SaveFile() [4/4]

bool SaveFile ( str  filename)

◆ SetError()

SetError ( int  err,
str  errorLocation,
TiXmlParsingData  prevData,
TiXmlEncoding  encoding 
)

◆ SetTabSize()

SetTabSize ( int  _tabsize)

SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column.

It does not change the output or input in any way.

By calling this method, with a tab size greater than 0, the row and column of each node and attribute is stored when the file is loaded. Very useful for tracking the DOM back in to the source file.

The tab size is required for calculating the location of nodes. If not set, the default of 4 is used. The tabsize is set per document. Setting the tabsize to 0 disables row/column tracking.

Note that row and column tracking is not supported when using operator>>.

The tab size needs to be enabled before the parse or load. Correct usage:

    TiXmlDocument doc;
    doc.SetTabSize( 8 );
    doc.Load( "myfile.xml" );
See also
Row, Column

◆ TabSize()

int TabSize ( )