Although the .NET Framework ships with a comprehensive XML library, Sam B's coworkers aren't big fans of it. It's far too fancy, they claim. Instead, they prefer to use StringBuilders, concatenation, and IndexOf(">")-style parsing.

"What on Earth do we need XML-Navigation and Nodes for," they'll often rhetorically say, "come on, it's all just string manipulation!" As it turns out, "XML-Navigation" and "Nodes" certainly do come in handy, especially when one needs to, say, navigate nodes in XML, as they'll often have do.

Fortunately though, they've built an entire library of "XML string" manipulating functions that they use for this exact purpose. Following is ParseText(), one of many of their functions...

''' <summary>
''' Convert text to XML compatible text, so it can be appended
''' instead of using a dom to add a node.
''' </summary>
''' <param name="textIn"></param>
''' <returns>String</returns>
''' <remarks></remarks>
Public Shared Function ParseText(ByVal textIn As String) As String

    Dim dom As XmlDocument = Nothing
    Dim Node As XmlElement = Nothing
    Dim Result As String
        dom = New XmlDocument
        Node = dom.CreateElement("x")
        Node.InnerText = textIn
        Result = Node.OuterXml
        If Result.Length() > 7 Then
            Return Mid(Result, 4, Result.Length() - 7)
            Return ""
        End If
    Catch ex As Exception
        Return ex.ToString
        dom = Nothing
        Node = Nothing
    End Try
End Function
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!