Unfortunately, I have a requirement to create some messy XML.
The main document must contain an embedded XML document. However, the embedded document runs in the CDATA section. The end result should look something like this:
<?xml version="1.0"?> <foo> <xml> <![CDATA[ <?xml version="1.0" encoding="UTF-8"?> <bar> </bar> ]]> </xml> </foo>
I ran into two problems:
Firstly, everything that is displayed in the CDATA section is displayed as escaped (for example, the sign greater than > becomes > )
Is there a way to disable shielding in the CDATA section?
Secondly, I cannot create an XML declaration. When I try to include an embedded XML document, I get the following exception:
def serializeEmbedded(): Seq[Node] = { <?xml version="1.0"?> <bar> </bar> } Exception in thread "main" java.lang.IllegalArgumentException: xml is reserved at scala.xml.ProcInstr.<init>(ProcInstr.scala:25)
This is my first foray into Scala's native XML processing.
Thanks,
Saish
Saish source share