From bdbfc08f96f89581bea277d5ddd9755e893067d7 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 16 Apr 2018 17:59:07 +0000 Subject: Convert CXFA_XMLLocale to CFX_XML This CL converts CXFA_XMLLocale to use CFX_XML instead of CXML. Change-Id: I1db617a658548ae5979f2f38d72c5b3000998663 Reviewed-on: https://pdfium-review.googlesource.com/30693 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- core/fxcrt/xml/cfx_xmlelement.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'core/fxcrt/xml/cfx_xmlelement.cpp') diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp index 530752e1dd..27d136305b 100644 --- a/core/fxcrt/xml/cfx_xmlelement.cpp +++ b/core/fxcrt/xml/cfx_xmlelement.cpp @@ -119,3 +119,25 @@ void CFX_XMLElement::Save( } pXMLStream->WriteString(ws.AsStringView()); } + +CFX_XMLElement* CFX_XMLElement::GetFirstChildNamed( + const WideStringView& name) const { + return GetNthChildNamed(name, 0); +} + +CFX_XMLElement* CFX_XMLElement::GetNthChildNamed(const WideStringView& name, + size_t idx) const { + for (auto* child = GetFirstChild(); child; child = child->GetNextSibling()) { + if (child->GetType() != FX_XMLNODE_Element) + continue; + + CFX_XMLElement* elem = static_cast(child); + if (elem->GetName() != name) + continue; + if (idx == 0) + return elem; + + --idx; + } + return nullptr; +} -- cgit v1.2.3