Replies: 5 comments
-
The challenge is that this is not quite valid Xml. Tag names are intended to be well-defined. I would consider custom parsing the best solution (if you do this in a custom serializer you can still parse the values using serialization). However, there are other options:
|
Beta Was this translation helpful? Give feedback.
-
Thank you! I've actually already started implementing the dynamic tag names approach serializing a Map instead of a List. Serializing the Map without nesting worked straightaway, but I have not successfully parsed out values with |
Beta Was this translation helpful? Give feedback.
-
@gladapps You don't need to go to raw parsing with regexes or something. You can use the (separate) xml parsing support from the core library. You just create your parser, then read events, if it is a tag handle it (read the value (perhaps recursively), then add it to your list). It is serialization that doesn't like it (it makes too many assumptions), not the xml parser. However, parsing a list of |
Beta Was this translation helpful? Give feedback.
-
@pdvrieze Is there an example of creating own parser with read events and tag handles? Would love to have a look at it. |
Beta Was this translation helpful? Give feedback.
-
@susrisha The way to go is to use the object Note that you don't need the serialization part of the library for this, only core. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to simply parse a format like this:
into a Map<String, String> with the entry keys being the tag names:
I've made my own policy that overrides
handleUnknownContentRecovering
and just puts the keys and values into a single Map like this:dataMap[input.name.toCName()] = input.elementContentToFragment().contentString
and returns the Map for
elementIndex = 0
. But I'm not sure what to do about the nested tags.I also need to serialize such a Map.
I've tried using the existing
MapEncoder
, but I don't need keys and values to have their own tags. Maybe it can work if the entry name could use the key name and omit the key element, with the value collapsed. But I couldn't figure out how to get it to do that.Any help would be greatly appreicated.
Beta Was this translation helpful? Give feedback.
All reactions