diff options
author | dan sinclair <dsinclair@chromium.org> | 2018-04-16 17:59:07 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-16 17:59:07 +0000 |
commit | bdbfc08f96f89581bea277d5ddd9755e893067d7 (patch) | |
tree | 3639bd042f64e5a93480a87e5a1d374ffe56a3e6 /core/fxcrt/xml/cfx_xmlelement.cpp | |
parent | cce4d31e6e746bae72f2f31676c12f1d2851ade3 (diff) | |
download | pdfium-bdbfc08f96f89581bea277d5ddd9755e893067d7.tar.xz |
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 <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_xmlelement.cpp')
-rw-r--r-- | core/fxcrt/xml/cfx_xmlelement.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
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<CFX_XMLElement*>(child); + if (elem->GetName() != name) + continue; + if (idx == 0) + return elem; + + --idx; + } + return nullptr; +} |