Classes | Macros | Functions

Detailed Description

Classes

class  XmlDocument
 Parses a text-based XML document and creates an XmlElement object from it. More...
 
class  XmlElement
 Used to build a tree of elements representing an XML document. More...
 
struct  XmlElement::TextFormat
 A struct containing options for formatting the text when representing an XML element as a string. More...
 

Macros

#define forEachXmlChildElement(parentXmlElement, childElementVariableName)   for (auto* (childElementVariableName) : ((parentXmlElement).macroBasedForLoop(), (parentXmlElement).getChildIterator()))
 DEPRECATED: A handy macro to make it easy to iterate all the child elements in an XmlElement. More...
 
#define forEachXmlChildElementWithTagName(parentXmlElement, childElementVariableName, requiredTagName)   for (auto* (childElementVariableName) : ((parentXmlElement).macroBasedForLoop(), (parentXmlElement).getChildWithTagNameIterator ((requiredTagName))))
 DEPRECATED: A macro that makes it easy to iterate all the child elements of an XmlElement which have a specified tag. More...
 

Functions

std::unique_ptr< XmlElementparseXML (const String &textToParse)
 Attempts to parse some XML text, returning a new XmlElement if it was valid. More...
 
std::unique_ptr< XmlElementparseXML (const File &fileToParse)
 Attempts to parse some XML text, returning a new XmlElement if it was valid. More...
 
std::unique_ptr< XmlElementparseXMLIfTagMatches (const String &textToParse, StringRef requiredTag)
 Does an inexpensive check to see whether the top-level element has the given tag name, and if that's true, does a full parse and returns the result. More...
 
std::unique_ptr< XmlElementparseXMLIfTagMatches (const File &fileToParse, StringRef requiredTag)
 Does an inexpensive check to see whether the top-level element has the given tag name, and if that's true, does a full parse and returns the result. More...
 

Macro Definition Documentation

◆ forEachXmlChildElement

#define forEachXmlChildElement (   parentXmlElement,
  childElementVariableName 
)    for (auto* (childElementVariableName) : ((parentXmlElement).macroBasedForLoop(), (parentXmlElement).getChildIterator()))

DEPRECATED: A handy macro to make it easy to iterate all the child elements in an XmlElement.

New code should avoid this macro, and instead use getChildIterator directly.

The parentXmlElement should be a reference to the parent XML, and the childElementVariableName will be the name of a pointer to each child element.

E.g.

XmlElement* myParentXml = createSomeKindOfXmlDocument();
forEachXmlChildElement (*myParentXml, child)
{
if (child->hasTagName ("FOO"))
doSomethingWithXmlElement (child);
}
See also
forEachXmlChildElementWithTagName

◆ forEachXmlChildElementWithTagName

#define forEachXmlChildElementWithTagName (   parentXmlElement,
  childElementVariableName,
  requiredTagName 
)    for (auto* (childElementVariableName) : ((parentXmlElement).macroBasedForLoop(), (parentXmlElement).getChildWithTagNameIterator ((requiredTagName))))

DEPRECATED: A macro that makes it easy to iterate all the child elements of an XmlElement which have a specified tag.

New code should avoid this macro, and instead use getChildWithTagNameIterator directly.

This does the same job as the forEachXmlChildElement macro, but only for those elements that have a particular tag name.

The parentXmlElement should be a reference to the parent XML, and the childElementVariableName will be the name of a pointer to each child element. The requiredTagName is the tag name to match.

E.g.

XmlElement* myParentXml = createSomeKindOfXmlDocument();
forEachXmlChildElementWithTagName (*myParentXml, child, "MYTAG")
{
// the child object is now guaranteed to be a <MYTAG> element..
doSomethingWithMYTAGElement (child);
}
See also
forEachXmlChildElement

Function Documentation

◆ parseXML() [1/2]

std::unique_ptr<XmlElement> parseXML ( const String textToParse)

Attempts to parse some XML text, returning a new XmlElement if it was valid.

If the parse fails, this will return a nullptr - if you need more information about errors or more parsing options, see the XmlDocument class instead.

See also
XmlDocument, parseXMLIfTagMatches

◆ parseXML() [2/2]

std::unique_ptr<XmlElement> parseXML ( const File fileToParse)

Attempts to parse some XML text, returning a new XmlElement if it was valid.

If the parse fails, this will return a nullptr - if you need more information about errors or more parsing options, see the XmlDocument class instead.

See also
XmlDocument, parseXMLIfTagMatches

◆ parseXMLIfTagMatches() [1/2]

std::unique_ptr<XmlElement> parseXMLIfTagMatches ( const String textToParse,
StringRef  requiredTag 
)

Does an inexpensive check to see whether the top-level element has the given tag name, and if that's true, does a full parse and returns the result.

If the outer tag doesn't match, or the XML has errors, this will return nullptr;

See also
parseXML

◆ parseXMLIfTagMatches() [2/2]

std::unique_ptr<XmlElement> parseXMLIfTagMatches ( const File fileToParse,
StringRef  requiredTag 
)

Does an inexpensive check to see whether the top-level element has the given tag name, and if that's true, does a full parse and returns the result.

If the outer tag doesn't match, or the XML has errors, this will return nullptr;

See also
parseXML
forEachXmlChildElement
#define forEachXmlChildElement(parentXmlElement, childElementVariableName)
DEPRECATED: A handy macro to make it easy to iterate all the child elements in an XmlElement.
Definition: juce_XmlElement.h:826
XmlElement
Used to build a tree of elements representing an XML document.
Definition: juce_XmlElement.h:85
forEachXmlChildElementWithTagName
#define forEachXmlChildElementWithTagName(parentXmlElement, childElementVariableName, requiredTagName)
DEPRECATED: A macro that makes it easy to iterate all the child elements of an XmlElement which have ...
Definition: juce_XmlElement.h:854