Skip to content

How to deserialize nested element ? #267

Answered by drmohundro
Benhajones asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, so I understand what the issue is here. The withAttribute method only returns a single attribute match, not all matches. That's why it is only returning the first match. You can see the implementation here: https://github.com/drmohundro/SWXMLHash/blob/main/Source/XMLIndexer.swift#L159.

Because you're wanting to filter on these types, you'll need to tweak the implementation slightly. Here is a test I wrote that works the way you're expecting:

    struct XMLPlacemark: XMLObjectDeserialization {
        var name: String
        var visibility: Int
        var address: String
        var description: String
        var styleUrl: String
        var cpnumber : Int
        var chargingdevice 

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@drmohundro
Comment options

Comment options

You must be logged in to vote
1 reply
@Benhajones
Comment options

Answer selected by Benhajones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants