CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
795 stars 107 forks source link

How to stop parsing subnode from some lower level #197

Open bitflying opened 4 years ago

bitflying commented 4 years ago

Hi, Friends,

For XML string,

<book id="123">
    <id>123</id>
    <title>Cat in the Hat</title>
    <category>Kids</category>
    <category>Wildlife</category>
    <description>Two bored children have their lives turned upside down when <italic>a talking cat</italic> comes to visit them.</description>
</book>

I hope the XMLCoder to parse tag id/title/category/description, not parse the tag in any more. So, book.description's content will be

"Two bored children have their lives turned upside down when <italic>a talking cat</italic> comes to visit them."

instead of

 "Two bored children have their lives turned upside down when a talking cat comes to visit them."

That means XMLCoder will stop to parse any node under tag description any more.

Is there any way to do so with XMLCoder?

Thanks in advance!

MaxDesiatov commented 4 years ago

Hi @bitflying, unfortunately there's no way to handle it this way. This is a limitation of Apple's XMLParserDelegate that Foundation provides. I don't think there's a way to tell Foundation's XML parser to avoid parsing content of a specific node.