I'm trying to merge/combine two xml strings that I got from parsing an object to XML using castor marshalling/unmarshalling. Here are the two XML strings that I have:
<?xml version="1.0" encoding="UTF-8"?>
<abc:abcResponse xmlns:abc="http://www.abc.com/schema/abcTransaction">
<abc:code>0</abc:code>
<abc:description>blah</abc:description>
</abc:abcResponse>
<?xml version="1.0" encoding="UTF-8"?>
<abc:abcRequest xmlns:abc="http://www.abc.com/schema/abcTransaction">
<abc:id>99999</abc:id>
<abc:idString>abc</abc:idString>
</abc:abcRequest>
I want to be able to combine these two strings into one so I can insert this into my database (MSSQL) column that has data type XML. I tried using the solution suggested from this link java merge two xml strings in java, but it doesn't seem to recognize it as a valid XML string since no records were inserted into the database table, and there's this error in my console:
com.microsoft.sqlserver.jdbc.SQLServerException: XML parsing: line 1, character 12, text/xmldecl not at the beginning of input
If I insert either of these strings separately into the database column then a new record will be added just fine.
Anyone has a good idea as to how to do this properly? Much thanks!