From c3d462ec9610726c12f6b8174a72ee46800f7c4d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Feb 2019 16:14:17 +0300 Subject: XmlGetChildByTag should search through all children of the same key --- protocols/JabberG/src/jabber_xml.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'protocols/JabberG/src/jabber_xml.cpp') diff --git a/protocols/JabberG/src/jabber_xml.cpp b/protocols/JabberG/src/jabber_xml.cpp index 142f0bc331..3f5496d145 100644 --- a/protocols/JabberG/src/jabber_xml.cpp +++ b/protocols/JabberG/src/jabber_xml.cpp @@ -182,14 +182,11 @@ int XmlGetChildInt(const TiXmlElement *hXml, const char *key) const TiXmlElement* XmlGetChildByTag(const TiXmlElement *hXml, const char *key, const char *attrName, const char *attrValue) { - if (hXml == nullptr) - return nullptr; - - auto *pChild = hXml->FirstChildElement(key); - if (pChild == nullptr) - return nullptr; + for (auto *pChild : TiXmlFilter(hXml, key)) + if (pChild->Attribute(attrName, attrValue)) + return pChild; - return (pChild->Attribute(attrName, attrValue)) ? pChild : nullptr; + return nullptr; } int XmlGetChildCount(const TiXmlElement *hXml) -- cgit v1.2.3