Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>VB conversion of the CDataWrapper in the accepted answer:</p> <pre><code>Imports System Imports System.IO Imports System.Runtime.Serialization Imports System.Xml Imports System.Xml.Schema Imports System.Xml.Serialization Imports System.ComponentModel Public Class CDataWrapper Implements IXmlSerializable 'underlying value Public Property Value As String 'Implicit to/from string Public Shared Widening Operator CType(ByVal value As CDataWrapper) As String If value Is Nothing Then Return Nothing Else Return value.Value End If End Operator Public Shared Widening Operator CType(value As String) As CDataWrapper If value Is Nothing Then Return Nothing Else Return New CDataWrapper() With {.Value = value} End If End Operator Public Function GetSchema() As XmlSchema Implements IXmlSerializable.GetSchema Return Nothing End Function ' &lt;Node/&gt; =&gt; "" ' &lt;Node&gt;&lt;/Node&gt; =&gt; "" ' &lt;Node&gt;Foo&lt;/Node&gt; =&gt; "Foo" ' &lt;Node&gt;&lt;![CDATA[Foo]]&gt;&lt;/Node&gt; =&gt; "Foo" Public Sub ReadXml(reader As XmlReader) Implements IXmlSerializable.ReadXml If reader.IsEmptyElement Then Me.Value = "" Else reader.Read() Select Case reader.NodeType Case XmlNodeType.EndElement Me.Value = "" ' empty after all... Case XmlNodeType.Text, XmlNodeType.CDATA Me.Value = reader.ReadContentAsString() Case Else Throw New InvalidOperationException("Expected text/cdata") End Select End If End Sub ' "" =&gt; &lt;Node/&gt; ' "Foo" =&gt; &lt;Node&gt;&lt;![CDATA[Foo]]&gt;&lt;/Node&gt; Public Sub WriteXml(writer As XmlWriter) Implements IXmlSerializable.WriteXml If Not String.IsNullOrEmpty(Me.Value) Then writer.WriteCData(Me.Value) End If End Sub Public Overrides Function ToString() As String Return Me.Value End Function End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload