Embedded XML

Discussion in 'XML' started by warrjo, Dec 17, 2004.

  1. warrjo

    warrjo Guest

    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.
     
    warrjo, Dec 17, 2004
    #1
    1. Advertising

  2. warrjo wrote:

    > 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.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 17, 2004
    #2
    1. Advertising

  3. warrjo

    Nobody Guest

    "warrjo" <> wrote in news:1103304638.843593.66560
    @f14g2000cwb.googlegroups.com:

    > 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
     
    Nobody, Dec 18, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Paul Gloster
    Replies:
    48
    Views:
    1,892
    Colin Paul Gloster
    Apr 10, 2007
  2. Avowkind

    handling xml embedded within xml

    Avowkind, May 19, 2008, in forum: Python
    Replies:
    0
    Views:
    224
    Avowkind
    May 19, 2008
  3. Thomas Dodds

    Databind an embedded control in an embedded datagrid

    Thomas Dodds, Jul 26, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    402
    Thomas Dodds
    Jul 26, 2004
  4. Trans
    Replies:
    11
    Views:
    302
    micathom
    Sep 5, 2007
  5. Num GG
    Replies:
    2
    Views:
    363
    Num GG
    Nov 17, 2008
Loading...

Share This Page