cezheng / Fuzi

A fast & lightweight XML & HTML parser in Swift with XPath & CSS support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

firstChild does not properly work with tag name `text`

Igor-Palaguta opened this issue · comments

Description:

  • Expected behaviour:
    element.firstChild(tag: "text") return first text node instead of element node with tag name "text"

  • Actual behaviour: returns element not text node

Environment

  • Package Manager:
    CocoaPods, version: 1.11.2

  • Fuzi version: 3.1.3

  • Xcode version: 13.4

How to reproduce:

<parent>
   <text>Some text</text>
</parent>

parent.firstChild(tag: "text")?.stringValue == " \n" instead of parent.firstChild(tag: "text")?.stringValue == "Some text"
parent.firstChild(tag: "text")?.type == .Text instead of parent.firstChild(tag: "text")?.type == .Element

parent.children(tag: "text") finds proper nodes as it checks also element type

@cezheng please have a look at #121