JUCE
Classes | Macros
juce_XmlElement.h File Reference

Classes

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

Macros

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

Macro Definition Documentation

#define forEachXmlChildElement (   parentXmlElement,
  childElementVariableName 
)
Value:
\
for (juce::XmlElement* childElementVariableName = (parentXmlElement).getFirstChildElement(); \
childElementVariableName != nullptr; \
childElementVariableName = childElementVariableName->getNextElement())

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

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.

1 XmlElement* myParentXml = createSomeKindOfXmlDocument();
2 
3 forEachXmlChildElement (*myParentXml, child)
4 {
5  if (child->hasTagName ("FOO"))
6  doSomethingWithXmlElement (child);
7 }
See also
forEachXmlChildElementWithTagName
#define forEachXmlChildElementWithTagName (   parentXmlElement,
  childElementVariableName,
  requiredTagName 
)
Value:
\
for (juce::XmlElement* childElementVariableName = (parentXmlElement).getChildByName (requiredTagName); \
childElementVariableName != nullptr; \
childElementVariableName = childElementVariableName->getNextElementWithTagName (requiredTagName))

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

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.

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