VB.NET • Copy One Element's Text as Another Element's Default Value

Listing 2. Many RSS 2.0-compliant newsreaders substitute the <body> element's contents for the <description> text when displaying an rss.xml file. The item_description_OnAfterChange event handler copies the <description> text to an empty XHTML <body> element when the completed Description textbox loses the focus. A similar event handler copies <link> contents to <guid>.

<InfoPathEventHandler(MatchPath:= _
     "/rss/channel/item/description", _
     EventType:=InfoPathEventType.OnAfterChange)> _
     Public Sub item_description_OnAfterChange _
     (ByVal e As DataDOMEvent)
     'Copy description to body if body is empty
     If e.IsUndoRedo Or e.Operation = "Delete" Then
     End If
     Dim strDescr As String = _
     If strDescr <> "" Then
          'Update the body element
          Dim nodBody As IXMLDOMNode = _
               e.Source.parentNode.selectSingleNode _
          If nodBody.text = "" Then
               nodBody.text = strDescr
          End If
     End If
End Sub