Deserialize whole node's inner text as string

  • Thread starter Thread starter Joerg Battermann
  • Start date Start date
J

Joerg Battermann

Hello there,

I 'have' to serialize xhtml within a xml-node without escaping /
wrapping it in CDATA tags, but also need to be able do deserialize it.

The structure looks e.g. like this:

<Requirement>
<IDNumber>1234</IDNumber>
<Description><html xmlns="http://www.w3.org/1999/xhtml"><head></
head><body><p>&nbsp;</p></body></html></Description>
</Requirement>


However, for the Description node The XMLReader sees another parent
node 'html', with the child-nodes head, body and one p node within the
later.

Is there a way to deserialize everything within the Description Part
as one big, raw string and skip the recursion down the x(ht)ml-nodes?

Cheers & thanks,
-Jörg
 
Joerg said:
I 'have' to serialize xhtml within a xml-node without escaping /
wrapping it in CDATA tags, but also need to be able do deserialize it.
Be aware that this actually cannot work 100% if you don't use the CDATA
approach. Your parser will give errors if the XHTML contains entities that
are defined in HTML but not in XML (like &eacute;). You can get around this
by supplying DTDs or with a custom XmlReader, but it's not pleasant.

Even CDATA is not completely trivial, because you must take care to break up
any ]]> sequences in the XHTML (CDATA doesn't nest), but it does avoid
problems with external references and imported namespaces.
The structure looks e.g. like this:

<Requirement>
<IDNumber>1234</IDNumber>
<Description><html xmlns="http://www.w3.org/1999/xhtml"><head></
head><body><p>&nbsp;</p></body></html></Description>
</Requirement>


However, for the Description node The XMLReader sees another parent
node 'html', with the child-nodes head, body and one p node within the
later.
Well, it should. :-)
Is there a way to deserialize everything within the Description Part
as one big, raw string and skip the recursion down the x(ht)ml-nodes?
..ReadInnerXml() should do it.
 
Back
Top