Embedded XML

W

warrjo

Hi. Is this correct? Can I embed an XML document within another XML
doc without encapsulating it in CDATA?

<?xml version="1.0"?>
<envelope>
<content>
<?xml version="1.0"?>
<title>someTitle</title>
<body type="text/html">
<![CDATA[<p>some malformed html content<br>]]>
</body>
</content>
<metadata>
<creator>somebody</creator>
</metadata>
</envelope>

Thank you.
 
M

Martin Honnen

warrjo said:
Is this correct? Can I embed an XML document within another XML
doc without encapsulating it in CDATA?

<?xml version="1.0"?>
<envelope>
<content>
<?xml version="1.0"?>
<title>someTitle</title>
<body type="text/html">
<![CDATA[<p>some malformed html content<br>]]>
</body>
</content>
<metadata>
<creator>somebody</creator>
</metadata>
</envelope>

I don't think it works, the XML declaration (<?xml version="1.0"?>)
cannot occur in the middle of a document.
 
N

Nobody

Hi. Is this correct? Can I embed an XML document within another XML
doc without encapsulating it in CDATA?

<?xml version="1.0"?>
<envelope>
<content>
<?xml version="1.0"?>
<title>someTitle</title>
<body type="text/html">
<![CDATA[<p>some malformed html content<br>]]>
</body>
</content>
<metadata>
<creator>somebody</creator>
</metadata>
</envelope>

Thank you.

Yes, but you need to 'escape' the nested document:

<?xml version="1.0"?>
<envelope>
<content>
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;title&gt;someTitle&lt;/title&gt;
&lt;body type=&quot;text/html&quot;&gt;
&lt;![CDATA[&lt;p&gt;some malformed html content&lt;br&gt;]]&gt;
&lt;/body&gt;
</content>
<metadata>
<creator>somebody</creator>
</metadata>
</envelope>

I do this with JAXB and it escapes it for me...

Good luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top