CoreOffice / XMLCoder

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

Extract all parts of the text #256

Open tomasbek opened 1 year ago

tomasbek commented 1 year ago

Dear All,

Thanks for this amazing project! I struggle to extract Text Part 2 from the following example.

<Result Identifier="123" Date="2022-12-01 12:00:00">
<Result.Description>
Text Part 1
<a href="xxx">Text Part 3</a>
Text Part 2
</Result.Description>
</Result>

My struct looks like this 👇

struct ResultDescription: Codable, DynamicNodeEncoding {
   let text: String // This extracts Text Part 1
   let reference: String? // This extracts Text Part 3
   enum CodingKeys: String, CodingKey {
      case text = ""
      case reference = "a"
   }
}

Any suggestions on how to extract Text Part 2?

Thanks 🙌

Joannis commented 1 year ago

@tomasbek, did you try approaching this as being a [String]?