From 319dda8e0bbaa6766abc50a887ccf46342f935d5 Mon Sep 17 00:00:00 2001 From: Igor Palaguta Date: Thu, 4 Aug 2022 10:45:52 +0200 Subject: [PATCH] Check element type in firstChild --- Fuzi.xcodeproj/project.pbxproj | 2 ++ Sources/Element.swift | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Fuzi.xcodeproj/project.pbxproj b/Fuzi.xcodeproj/project.pbxproj index c2dcf34..a50e063 100644 --- a/Fuzi.xcodeproj/project.pbxproj +++ b/Fuzi.xcodeproj/project.pbxproj @@ -109,7 +109,9 @@ 7913918B1B53B09F00BC07C3 /* Tests */, 7913917E1B53B09F00BC07C3 /* Products */, ); + indentWidth = 2; sourceTree = ""; + tabWidth = 2; }; 7913917E1B53B09F00BC07C3 /* Products */ = { isa = PBXGroup; diff --git a/Sources/Element.swift b/Sources/Element.swift index f42bada..e7858ee 100644 --- a/Sources/Element.swift +++ b/Sources/Element.swift @@ -112,7 +112,7 @@ open class XMLElement: XMLNode { open func firstChild(tag: XMLCharsComparable, inNamespace ns: XMLCharsComparable? = nil) -> XMLElement? { var nodePtr = cNode.pointee.children while let cNode = nodePtr { - if cXMLNode(nodePtr, matchesTag: tag, inNamespace: ns) { + if cNode.pointee.type == XML_ELEMENT_NODE && cXMLNode(nodePtr, matchesTag: tag, inNamespace: ns) { return XMLElement(cNode: cNode, document: self.document) } nodePtr = cNode.pointee.next