mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added method XmlElement::getChildByAttribute().
This commit is contained in:
parent
a811a80884
commit
4198291d9a
2 changed files with 24 additions and 1 deletions
|
|
@ -562,6 +562,8 @@ XmlElement* XmlElement::getChildElement (const int index) const noexcept
|
|||
|
||||
XmlElement* XmlElement::getChildByName (StringRef childName) const noexcept
|
||||
{
|
||||
jassert (! childName.isEmpty());
|
||||
|
||||
for (XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem)
|
||||
if (child->hasTagName (childName))
|
||||
return child;
|
||||
|
|
@ -569,6 +571,17 @@ XmlElement* XmlElement::getChildByName (StringRef childName) const noexcept
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
XmlElement* XmlElement::getChildByAttribute (StringRef attributeName, StringRef attributeValue) const noexcept
|
||||
{
|
||||
jassert (! attributeName.isEmpty());
|
||||
|
||||
for (XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem)
|
||||
if (child->compareAttribute (attributeName, attributeValue))
|
||||
return child;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void XmlElement::addChildElement (XmlElement* const newNode) noexcept
|
||||
{
|
||||
if (newNode != nullptr)
|
||||
|
|
|
|||
|
|
@ -483,10 +483,20 @@ public:
|
|||
|
||||
@param tagNameToLookFor the tag name of the element you want to find
|
||||
@returns the first element with this tag name, or nullptr if none is found
|
||||
@see getNextElement, isTextElement, getChildElement
|
||||
@see getNextElement, isTextElement, getChildElement, getChildByAttribute
|
||||
*/
|
||||
XmlElement* getChildByName (StringRef tagNameToLookFor) const noexcept;
|
||||
|
||||
/** Returns the first sub-element which has an attribute that matches the given value.
|
||||
|
||||
@param attributeName the name of the attribute to check
|
||||
@param attributeValue the target value of the attribute
|
||||
@returns the first element with this attribute value, or nullptr if none is found
|
||||
@see getChildByName
|
||||
*/
|
||||
XmlElement* getChildByAttribute (StringRef attributeName,
|
||||
StringRef attributeValue) const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Appends an element to this element's list of children.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue