Skip to content

Specify starting node for decoding #71

@Eitot

Description

@Eitot

Perhaps I am overlooking this, but I think it would be useful if the starting node could be specified in some way, perhaps via XPath. While trying to implement an RSS feed, I found that I either have to implement the parent node to get to the child nodes I am interested in or write my own init(from decoder: Decoder).

For example:

<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Title</title>
…
  </channel>
</rss>

To get to the title node, I need to implement a type for the channel node as well:

struct RSSFeed: Decodable {
  let channel: Channel

  struct Channel: Decodable {
    let title: String
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions