Closed levinotik closed 9 months ago
I think your only options are to
parse
methods to take that string from your xmlMapper to parse it to a Node and then append it. It should work but it's not probably not the most efficient path since it requires serializing to a string just to parse it back to objects.I haven't looked too much into jackson XmlMapper but I'm assuming it's similar enough to the json mapper. I can probably look into something to hook into jackson to more efficiently build a Node object from the mapper.
I'll keep you posted on that.
@redundent thanks very much for the reply. Appreciate it!
Firstly, thank you for this excellent library.
While this might not be a formal issue, I'm seeking guidance on a matter that involves nesting one XML node within another. Here's my scenario: I have a function that accepts an object that can be serialized to XML as an argument. Within this function, my objective is to create XML using the kotlin-xml-builder DSL (utilizing functions like
xml(..)
), and include the serialized object as part of the constructed XML. Currently, I've achieved this by usingunsafeText
, but I'm hopeful there might be a more elegant solution.In the code snippet above,
xmlMapper
is an instance ofcom.fasterxml.jackson.dataformat.xml.XmlMapper
, andwriteValueAsString
serializes the object into an XML string.I'm curious if there's a recommended technique to accomplish this task. Specifically, I'm looking for a way to encapsulate existing XML within an outer XML document generated using DSL syntax.
Thanks in advance for the help!