LMMS
Loading...
Searching...
No Matches
water::XmlElement Class Reference

#include <XmlElement.h>

Classes

struct  XmlAttributeNode

Public Member Functions

 XmlElement (const String &tagName)
 XmlElement (const char *tagName)
 XmlElement (const Identifier &tagName)
 XmlElement (StringRef tagName)
 XmlElement (CharPointer_UTF8 tagNameBegin, CharPointer_UTF8 tagNameEnd)
 XmlElement (const XmlElement &)
XmlElementoperator= (const XmlElement &)
 ~XmlElement () noexcept
bool isEquivalentTo (const XmlElement *other, bool ignoreOrderOfAttributes) const noexcept
String createDocument (StringRef dtdToUse, bool allOnOneLine=false, bool includeXmlHeader=true, StringRef encodingType="UTF-8", int lineWrapLength=60) const
void writeToStream (OutputStream &output, StringRef dtdToUse, bool allOnOneLine=false, bool includeXmlHeader=true, StringRef encodingType="UTF-8", int lineWrapLength=60) const
const StringgetTagName () const noexcept
String getNamespace () const
String getTagNameWithoutNamespace () const
bool hasTagName (StringRef possibleTagName) const noexcept
bool hasTagNameIgnoringNamespace (StringRef possibleTagName) const
int getNumAttributes () const noexcept
const std::string & getAttributeName (int attributeIndex) const noexcept
const StringgetAttributeValue (int attributeIndex) const noexcept
bool hasAttribute (StringRef attributeName) const noexcept
const StringgetStringAttribute (StringRef attributeName) const noexcept
String getStringAttribute (StringRef attributeName, const String &defaultReturnValue) const
bool compareAttribute (StringRef attributeName, StringRef stringToCompareAgainst, bool ignoreCase=false) const noexcept
int getIntAttribute (StringRef attributeName, int defaultReturnValue=0) const
double getDoubleAttribute (StringRef attributeName, double defaultReturnValue=0.0) const
bool getBoolAttribute (StringRef attributeName, bool defaultReturnValue=false) const
void setAttribute (const Identifier &attributeName, const String &newValue)
void setAttribute (const Identifier &attributeName, int newValue)
void setAttribute (const Identifier &attributeName, double newValue)
void removeAttribute (const Identifier &attributeName) noexcept
void removeAllAttributes () noexcept
XmlElementgetFirstChildElement () const noexcept
XmlElementgetNextElement () const noexcept
XmlElementgetNextElementWithTagName (StringRef requiredTagName) const
int getNumChildElements () const noexcept
XmlElementgetChildElement (int index) const noexcept
XmlElementgetChildByName (StringRef tagNameToLookFor) const noexcept
XmlElementgetChildByAttribute (StringRef attributeName, StringRef attributeValue) const noexcept
void addChildElement (XmlElement *newChildElement) noexcept
void insertChildElement (XmlElement *newChildElement, int indexToInsertAt) noexcept
void prependChildElement (XmlElement *newChildElement) noexcept
XmlElementcreateNewChildElement (StringRef tagName)
bool replaceChildElement (XmlElement *currentChildElement, XmlElement *newChildNode) noexcept
void removeChildElement (XmlElement *childToRemove, bool shouldDeleteTheChild) noexcept
void deleteAllChildElements () noexcept
void deleteAllChildElementsWithTagName (StringRef tagName) noexcept
bool containsChildElement (const XmlElement *possibleChild) const noexcept
XmlElementfindParentElementOf (const XmlElement *childToSearchFor) noexcept
bool isTextElement () const noexcept
const StringgetText () const noexcept
void setText (const String &newText)
String getAllSubText () const
String getChildElementAllSubText (StringRef childTagName, const String &defaultReturnValue) const
void addTextElement (const String &text)
void deleteAllTextElements () noexcept

Static Public Member Functions

static XmlElementcreateTextElement (const String &text)
static bool isValidXmlName (StringRef possibleName) noexcept

Private Member Functions

 XmlElement (int) noexcept
void copyChildrenAndAttributesFrom (const XmlElement &)
void writeElementAsText (OutputStream &, int indentationLevel, int lineWrapLength) const
void getChildElementsAsArray (XmlElement **) const noexcept
void reorderChildElements (XmlElement **, int) noexcept
XmlAttributeNodegetAttribute (StringRef) const noexcept

Private Attributes

LinkedListPointer< XmlElementnextListItem
LinkedListPointer< XmlElementfirstChildElement
LinkedListPointer< XmlAttributeNodeattributes
String tagName

Friends

class XmlDocument
class LinkedListPointer< XmlAttributeNode >
class LinkedListPointer< XmlElement >
class LinkedListPointer< XmlElement >::Appender
class NamedValueSet

Detailed Description

Used to build a tree of elements representing an XML document.

An XML document can be parsed into a tree of XmlElements, each of which represents an XML tag structure, and which may itself contain other nested elements.

An XmlElement can also be converted back into a text document, and has lots of useful methods for manipulating its attributes and sub-elements, so XmlElements can actually be used as a handy general-purpose data structure.

Here's an example of parsing some elements:

// check we're looking at the right kind of document..
if (myElement->hasTagName ("ANIMALS"))
{
// now we'll iterate its sub-elements looking for 'giraffe' elements..
forEachXmlChildElement (*myElement, e)
{
if (e->hasTagName ("GIRAFFE"))
{
// found a giraffe, so use some of its attributes..
String giraffeName = e->getStringAttribute ("name");
int giraffeAge = e->getIntAttribute ("age");
bool isFriendly = e->getBoolAttribute ("friendly");
}
}
}
Definition String.h:48
* e
Definition inflate.c:1404
#define forEachXmlChildElement(parentXmlElement, childElementVariableName)
Definition juce_XmlElement.h:824

And here's an example of how to create an XML document from scratch:

// create an outer node called "ANIMALS"
XmlElement animalsList ("ANIMALS");
for (int i = 0; i < numAnimals; ++i)
{
// create an inner element..
XmlElement* giraffe = new XmlElement ("GIRAFFE");
giraffe->setAttribute ("name", "nigel");
giraffe->setAttribute ("age", 10);
giraffe->setAttribute ("friendly", true);
// ..and add our new element to the parent node
animalsList.addChildElement (giraffe);
}
// now we can turn the whole thing into a text document..
String myXmlDoc = animalsList.createDocument (String());
XmlElement(const String &tagName)
Definition XmlElement.cpp:83
void setAttribute(const Identifier &attributeName, const String &newValue)
Definition XmlElement.cpp:548
register unsigned i
Definition inflate.c:1575
See also
XmlDocument

Constructor & Destructor Documentation

◆ XmlElement() [1/7]

water::XmlElement::XmlElement ( const String & tagName)
explicit

Creates an XmlElement with this tag name.

◆ XmlElement() [2/7]

water::XmlElement::XmlElement ( const char * tagName)
explicit

Creates an XmlElement with this tag name.

◆ XmlElement() [3/7]

water::XmlElement::XmlElement ( const Identifier & tagName)
explicit

Creates an XmlElement with this tag name.

◆ XmlElement() [4/7]

water::XmlElement::XmlElement ( StringRef tagName)
explicit

Creates an XmlElement with this tag name.

◆ XmlElement() [5/7]

water::XmlElement::XmlElement ( CharPointer_UTF8 tagNameBegin,
CharPointer_UTF8 tagNameEnd )

Creates an XmlElement with this tag name.

◆ XmlElement() [6/7]

water::XmlElement::XmlElement ( const XmlElement & other)

Creates a (deep) copy of another element.

◆ ~XmlElement()

water::XmlElement::~XmlElement ( )
noexcept

Deleting an XmlElement will also delete all of its child elements.

◆ XmlElement() [7/7]

water::XmlElement::XmlElement ( int )
privatenoexcept

Member Function Documentation

◆ addChildElement()

void water::XmlElement::addChildElement ( XmlElement * newChildElement)
noexcept

Appends an element to this element's list of children.

Child elements are deleted automatically when their parent is deleted, so make sure the object that you pass in will not be deleted by anything else, and make sure it's not already the child of another element.

Note that due to the XmlElement using a singly-linked-list, prependChildElement() is an O(1) operation, but addChildElement() is an O(N) operation - so if you're adding large number of elements, you may prefer to do so in reverse order!

See also
getFirstChildElement, getNextElement, getNumChildElements, getChildElement, removeChildElement

◆ addTextElement()

void water::XmlElement::addTextElement ( const String & text)

Appends a section of text to this element.

See also
isTextElement, getText, getAllSubText

◆ compareAttribute()

bool water::XmlElement::compareAttribute ( StringRef attributeName,
StringRef stringToCompareAgainst,
bool ignoreCase = false ) const
noexcept

Compares the value of a named attribute with a value passed-in.

Parameters
attributeNamethe name of the attribute to look up
stringToCompareAgainstthe value to compare it with
ignoreCasewhether the comparison should be case-insensitive
Returns
true if the value of the attribute is the same as the string passed-in; false if it's different (or if no such attribute exists)

◆ containsChildElement()

bool water::XmlElement::containsChildElement ( const XmlElement * possibleChild) const
noexcept

Returns true if the given element is a child of this one.

◆ copyChildrenAndAttributesFrom()

void water::XmlElement::copyChildrenAndAttributesFrom ( const XmlElement & other)
private

◆ createDocument()

String water::XmlElement::createDocument ( StringRef dtdToUse,
bool allOnOneLine = false,
bool includeXmlHeader = true,
StringRef encodingType = "UTF-8",
int lineWrapLength = 60 ) const

Returns an XML text document that represents this element.

The string returned can be parsed to recreate the same XmlElement that was used to create it.

Parameters
dtdToUsethe DTD to add to the document
allOnOneLineif true, this means that the document will not contain any linefeeds, so it'll be smaller but not very easy to read.
includeXmlHeaderwhether to add the "<?xml version..etc" line at the start of the document
encodingTypethe character encoding format string to put into the xml header
lineWrapLengththe line length that will be used before items get placed on a new line. This isn't an absolute maximum length, it just determines how lists of attributes get broken up
See also
writeToStream, writeToFile

◆ createNewChildElement()

XmlElement * water::XmlElement::createNewChildElement ( StringRef tagName)

Creates a new element with the given name and returns it, after adding it as a child element.

This is a handy method that means that instead of writing this:

XmlElement* newElement = new XmlElement ("foobar");
myParentElement->addChildElement (newElement);

..you could just write this:

XmlElement* newElement = myParentElement->createNewChildElement ("foobar");
XmlElement * createNewChildElement(StringRef tagName)
Definition XmlElement.cpp:668

◆ createTextElement()

XmlElement * water::XmlElement::createTextElement ( const String & text)
static

Creates a text element that can be added to a parent element.

◆ deleteAllChildElements()

void water::XmlElement::deleteAllChildElements ( )
noexcept

Deletes all the child elements in the element.

See also
removeChildElement, deleteAllChildElementsWithTagName

◆ deleteAllChildElementsWithTagName()

void water::XmlElement::deleteAllChildElementsWithTagName ( StringRef tagName)
noexcept

Deletes all the child elements with a given tag name.

See also
removeChildElement

◆ deleteAllTextElements()

void water::XmlElement::deleteAllTextElements ( )
noexcept

Removes all the text elements from this element.

See also
isTextElement, getText, getAllSubText, addTextElement

◆ findParentElementOf()

XmlElement * water::XmlElement::findParentElementOf ( const XmlElement * childToSearchFor)
noexcept

Recursively searches all sub-elements of this one, looking for an element which is the direct parent of the specified element.

Because elements don't store a pointer to their parent, if you have one and need to find its parent, the only way to do so is to exhaustively search the whole tree for it.

If the given child is found somewhere in this element's hierarchy, then this method will return its parent. If not, it will return nullptr.

◆ getAllSubText()

String water::XmlElement::getAllSubText ( ) const

Returns all the text from this element's child nodes.

This iterates all the child elements and when it finds text elements, it concatenates their text into a big string which it returns.

E.g.

<xyz>hello <x>there</x> world</xyz>
unsigned x[BMAX+1]
Definition inflate.c:1586
static LilvWorld * world
Definition lilv_test.c:64

if you called getAllSubText on the "xyz" element, it'd return "hello there world".

Note that leading and trailing whitespace will be included in the string - to remove if, just call String::trim() on the result.

See also
isTextElement, getChildElementAllSubText, getText, addTextElement

◆ getAttribute()

XmlElement::XmlAttributeNode * water::XmlElement::getAttribute ( StringRef attributeName) const
privatenoexcept

◆ getAttributeName()

const std::string & water::XmlElement::getAttributeName ( int attributeIndex) const
noexcept

Returns the name of one of the elements attributes.

E.g. for an element such as <MOOSE legs="4" antlers="2">, then getAttributeName(1) would return "antlers".

See also
getAttributeValue, getStringAttribute

◆ getAttributeValue()

const String & water::XmlElement::getAttributeValue ( int attributeIndex) const
noexcept

Returns the value of one of the elements attributes.

E.g. for an element such as <MOOSE legs="4" antlers="2">, then getAttributeName(1) would return "2".

See also
getAttributeName, getStringAttribute

◆ getBoolAttribute()

bool water::XmlElement::getBoolAttribute ( StringRef attributeName,
bool defaultReturnValue = false ) const

Returns the value of a named attribute as a boolean.

This will try to find the attribute and interpret it as a boolean. To do this, it'll return true if the value is "1", "true", "y", etc, or false for other values.

Parameters
attributeNamethe name of the attribute to look up
defaultReturnValuea value to return if the element doesn't have an attribute with this name

◆ getChildByAttribute()

XmlElement * water::XmlElement::getChildByAttribute ( StringRef attributeName,
StringRef attributeValue ) const
noexcept

Returns the first sub-element which has an attribute that matches the given value.

Parameters
attributeNamethe name of the attribute to check
attributeValuethe target value of the attribute
Returns
the first element with this attribute value, or nullptr if none is found
See also
getChildByName

◆ getChildByName()

XmlElement * water::XmlElement::getChildByName ( StringRef tagNameToLookFor) const
noexcept

Returns the first sub-element with a given tag-name.

Parameters
tagNameToLookForthe tag name of the element you want to find
Returns
the first element with this tag name, or nullptr if none is found
See also
getNextElement, isTextElement, getChildElement, getChildByAttribute

◆ getChildElement()

XmlElement * water::XmlElement::getChildElement ( int index) const
noexcept

Returns the sub-element at a certain index.

It's not very efficient to iterate the sub-elements by index - see getNextElement() for an example of how best to iterate.

Returns
the n'th child of this element, or nullptr if the index is out-of-range
See also
getNextElement, isTextElement, getChildByName

◆ getChildElementAllSubText()

String water::XmlElement::getChildElementAllSubText ( StringRef childTagName,
const String & defaultReturnValue ) const

Returns all the sub-text of a named child element.

If there is a child element with the given tag name, this will return all of its sub-text (by calling getAllSubText() on it). If there is no such child element, this will return the default string passed-in.

See also
getAllSubText

◆ getChildElementsAsArray()

void water::XmlElement::getChildElementsAsArray ( XmlElement ** elems) const
privatenoexcept

◆ getDoubleAttribute()

double water::XmlElement::getDoubleAttribute ( StringRef attributeName,
double defaultReturnValue = 0.0 ) const

Returns the value of a named attribute as floating-point.

This will try to find the attribute and convert it to a double (using the String::getDoubleValue() method).

Parameters
attributeNamethe name of the attribute to look up
defaultReturnValuea value to return if the element doesn't have an attribute with this name
See also
setAttribute

◆ getFirstChildElement()

XmlElement * water::XmlElement::getFirstChildElement ( ) const
inlinenoexcept

Returns the first of this element's sub-elements. see getNextElement() for an example of how to iterate the sub-elements.

See also
forEachXmlChildElement

◆ getIntAttribute()

int water::XmlElement::getIntAttribute ( StringRef attributeName,
int defaultReturnValue = 0 ) const

Returns the value of a named attribute as an integer.

This will try to find the attribute and convert it to an integer (using the String::getIntValue() method).

Parameters
attributeNamethe name of the attribute to look up
defaultReturnValuea value to return if the element doesn't have an attribute with this name
See also
setAttribute

◆ getNamespace()

String water::XmlElement::getNamespace ( ) const

Returns the namespace portion of the tag-name, or an empty string if none is specified.

◆ getNextElement()

XmlElement * water::XmlElement::getNextElement ( ) const
inlinenoexcept

Returns the next of this element's siblings.

This can be used for iterating an element's sub-elements, e.g.

XmlElement* child = myXmlDocument->getFirstChildElement();
while (child != nullptr)
{
...do stuff with this child..
child = child->getNextElement();
}
XmlElement * getNextElement() const noexcept
Definition XmlElement.h:464

Note that when iterating the child elements, some of them might be text elements as well as XML tags - use isTextElement() to work this out.

Also, it's much easier and neater to use this method indirectly via the forEachXmlChildElement macro.

Returns
the sibling element that follows this one, or a nullptr if this is the last element in its parent
See also
getNextElement, isTextElement, forEachXmlChildElement

◆ getNextElementWithTagName()

XmlElement * water::XmlElement::getNextElementWithTagName ( StringRef requiredTagName) const

Returns the next of this element's siblings which has the specified tag name.

This is like getNextElement(), but will scan through the list until it finds an element with the given tag name.

See also
getNextElement, forEachXmlChildElementWithTagName

◆ getNumAttributes()

int water::XmlElement::getNumAttributes ( ) const
noexcept

Returns the number of XML attributes this element contains.

E.g. for an element such as <MOOSE legs="4" antlers="2">, this would return 2.

◆ getNumChildElements()

int water::XmlElement::getNumChildElements ( ) const
noexcept

Returns the number of sub-elements in this element.

See also
getChildElement

◆ getStringAttribute() [1/2]

const String & water::XmlElement::getStringAttribute ( StringRef attributeName) const
noexcept

Returns the value of a named attribute.

Parameters
attributeNamethe name of the attribute to look up

◆ getStringAttribute() [2/2]

String water::XmlElement::getStringAttribute ( StringRef attributeName,
const String & defaultReturnValue ) const

Returns the value of a named attribute.

Parameters
attributeNamethe name of the attribute to look up
defaultReturnValuea value to return if the element doesn't have an attribute with this name

◆ getTagName()

const String & water::XmlElement::getTagName ( ) const
inlinenoexcept

Returns this element's tag type name. E.g. for an element such as <MOOSE legs="4" antlers="2">, this would return "MOOSE".

See also
hasTagName

◆ getTagNameWithoutNamespace()

String water::XmlElement::getTagNameWithoutNamespace ( ) const

Returns the part of the tag-name that follows any namespace declaration.

◆ getText()

const String & water::XmlElement::getText ( ) const
noexcept

Returns the text for a text element.

Note that if you have an element like this:

<xyz>hello</xyz>

then calling getText on the "xyz" element won't return "hello", because that is actually stored in a special text sub-element inside the xyz element. To get the "hello" string, you could either call getText on the (unnamed) sub-element, or use getAllSubText() to do this automatically.

Note that leading and trailing whitespace will be included in the string - to remove if, just call String::trim() on the result.

See also
isTextElement, getAllSubText, getChildElementAllSubText

◆ hasAttribute()

bool water::XmlElement::hasAttribute ( StringRef attributeName) const
noexcept

Checks whether the element contains an attribute with a certain name.

◆ hasTagName()

bool water::XmlElement::hasTagName ( StringRef possibleTagName) const
noexcept

Tests whether this element has a particular tag name.

Parameters
possibleTagNamethe tag name you're comparing it with
See also
getTagName

◆ hasTagNameIgnoringNamespace()

bool water::XmlElement::hasTagNameIgnoringNamespace ( StringRef possibleTagName) const

Tests whether this element has a particular tag name, ignoring any XML namespace prefix. So a test for e.g. "xyz" will return true for "xyz" and also "foo:xyz", "bar::xyz", etc.

See also
getTagName

◆ insertChildElement()

void water::XmlElement::insertChildElement ( XmlElement * newChildElement,
int indexToInsertAt )
noexcept

Inserts an element into this element's list of children.

Child elements are deleted automatically when their parent is deleted, so make sure the object that you pass in will not be deleted by anything else, and make sure it's not already the child of another element.

Parameters
newChildElementthe element to add
indexToInsertAtthe index at which to insert the new element - if this is below zero, it will be added to the end of the list
See also
addChildElement, insertChildElement

◆ isEquivalentTo()

bool water::XmlElement::isEquivalentTo ( const XmlElement * other,
bool ignoreOrderOfAttributes ) const
noexcept

Compares two XmlElements to see if they contain the same text and attiributes.

The elements are only considered equivalent if they contain the same attiributes with the same values, and have the same sub-nodes.

Parameters
otherthe other element to compare to
ignoreOrderOfAttributesif true, this means that two elements with the same attributes in a different order will be considered the same; if false, the attributes must be in the same order as well

◆ isTextElement()

bool water::XmlElement::isTextElement ( ) const
noexcept

Returns true if this element is a section of text.

Elements can either be an XML tag element or a secton of text, so this is used to find out what kind of element this one is.

See also
getAllText, addTextElement, deleteAllTextElements

◆ isValidXmlName()

bool water::XmlElement::isValidXmlName ( StringRef possibleName)
staticnoexcept

Checks if a given string is a valid XML name

◆ operator=()

XmlElement & water::XmlElement::operator= ( const XmlElement & other)

Creates a (deep) copy of another element.

◆ prependChildElement()

void water::XmlElement::prependChildElement ( XmlElement * newChildElement)
noexcept

Inserts an element at the beginning of this element's list of children.

Child elements are deleted automatically when their parent is deleted, so make sure the object that you pass in will not be deleted by anything else, and make sure it's not already the child of another element.

Note that due to the XmlElement using a singly-linked-list, prependChildElement() is an O(1) operation, but addChildElement() is an O(N) operation - so if you're adding large number of elements, you may prefer to do so in reverse order!

See also
addChildElement, insertChildElement

◆ removeAllAttributes()

void water::XmlElement::removeAllAttributes ( )
noexcept

Removes all attributes from this element.

◆ removeAttribute()

void water::XmlElement::removeAttribute ( const Identifier & attributeName)
noexcept

Removes a named attribute from the element.

Parameters
attributeNamethe name of the attribute to remove
See also
removeAllAttributes

◆ removeChildElement()

void water::XmlElement::removeChildElement ( XmlElement * childToRemove,
bool shouldDeleteTheChild )
noexcept

Removes a child element.

Parameters
childToRemovethe child to look for and remove
shouldDeleteTheChildif true, the child will be deleted, if false it'll just remove it

◆ reorderChildElements()

void water::XmlElement::reorderChildElements ( XmlElement ** elems,
int num )
privatenoexcept

◆ replaceChildElement()

bool water::XmlElement::replaceChildElement ( XmlElement * currentChildElement,
XmlElement * newChildNode )
noexcept

Replaces one of this element's children with another node.

If the current element passed-in isn't actually a child of this element, this will return false and the new one won't be added. Otherwise, the existing element will be deleted, replaced with the new one, and it will return true.

◆ setAttribute() [1/3]

void water::XmlElement::setAttribute ( const Identifier & attributeName,
const String & newValue )

Adds a named attribute to the element.

If the element already contains an attribute with this name, it's value will be updated to the new value. If there's no such attribute yet, a new one will be added.

Note that there are other setAttribute() methods that take integers, doubles, etc. to make it easy to store numbers.

Parameters
attributeNamethe name of the attribute to set
newValuethe value to set it to
See also
removeAttribute

◆ setAttribute() [2/3]

void water::XmlElement::setAttribute ( const Identifier & attributeName,
double newValue )

Adds a named attribute to the element, setting it to a floating-point value.

If the element already contains an attribute with this name, it's value will be updated to the new value. If there's no such attribute yet, a new one will be added.

Note that there are other setAttribute() methods that take integers, doubles, etc. to make it easy to store numbers.

Parameters
attributeNamethe name of the attribute to set
newValuethe value to set it to

◆ setAttribute() [3/3]

void water::XmlElement::setAttribute ( const Identifier & attributeName,
int newValue )

Adds a named attribute to the element, setting it to an integer value.

If the element already contains an attribute with this name, it's value will be updated to the new value. If there's no such attribute yet, a new one will be added.

Note that there are other setAttribute() methods that take integers, doubles, etc. to make it easy to store numbers.

Parameters
attributeNamethe name of the attribute to set
newValuethe value to set it to

◆ setText()

void water::XmlElement::setText ( const String & newText)

Sets the text in a text element.

Note that this is only a valid call if this element is a text element. If it's not, then no action will be performed. If you're trying to add text inside a normal element, you probably want to use addTextElement() instead.

◆ writeElementAsText()

void water::XmlElement::writeElementAsText ( OutputStream & outputStream,
int indentationLevel,
int lineWrapLength ) const
private

◆ writeToStream()

void water::XmlElement::writeToStream ( OutputStream & output,
StringRef dtdToUse,
bool allOnOneLine = false,
bool includeXmlHeader = true,
StringRef encodingType = "UTF-8",
int lineWrapLength = 60 ) const

Writes the document to a stream as UTF-8.

Parameters
outputthe stream to write to
dtdToUsethe DTD to add to the document
allOnOneLineif true, this means that the document will not contain any linefeeds, so it'll be smaller but not very easy to read.
includeXmlHeaderwhether to add the "<?xml version..etc" line at the start of the document
encodingTypethe character encoding format string to put into the xml header
lineWrapLengththe line length that will be used before items get placed on a new line. This isn't an absolute maximum length, it just determines how lists of attributes get broken up
See also
writeToFile, createDocument

◆ LinkedListPointer< XmlAttributeNode >

friend class LinkedListPointer< XmlAttributeNode >
friend

◆ LinkedListPointer< XmlElement >

friend class LinkedListPointer< XmlElement >
friend

◆ LinkedListPointer< XmlElement >::Appender

friend class LinkedListPointer< XmlElement >::Appender
friend

◆ NamedValueSet

friend class NamedValueSet
friend

◆ XmlDocument

friend class XmlDocument
friend

Member Data Documentation

◆ attributes

LinkedListPointer<XmlAttributeNode> water::XmlElement::attributes
private

◆ firstChildElement

LinkedListPointer<XmlElement> water::XmlElement::firstChildElement
private

◆ nextListItem

LinkedListPointer<XmlElement> water::XmlElement::nextListItem
private

◆ tagName

String water::XmlElement::tagName
private

The documentation for this class was generated from the following files: