CS程序中XML编码Encode和解码Decode

VB6的代码,原则上只要是Windows系统均可以使用此方法

Function XMLEncode(ByVal text As String) As String
    Dim xmldoc
    Set xmldoc = CreateObject("Microsoft.XMLDOM")
    Dim e As IXMLDOMElement
    Set e = xmldoc.createElement("a")
    e.text = text
    XMLEncode = Mid(e.xml, 4, Len(e.xml) - 7)
End Function

Function XMLDecode(ByVal xml As String) As String
    Dim xmldoc
    Set xmldoc = CreateObject("Microsoft.XMLDOM")
    xmldoc.loadXML "<a>" & xml & "</a>"
    Dim e As IXMLDOMElement
    Set e = xmldoc.selectSingleNode("a")
    XMLDecode = e.text
End Function

'需引用程序集 Microsoft.XML

posted on 2017-04-03 21:49  空明流光  阅读(718)  评论(0编辑  收藏  举报

导航