XML是标记文件,你想把一个2进制文件放在里面??它的解释器无法解读的,HTML是XML的一个子集,你看它的做法就知道了,一个链接。

解决方案 »

  1.   

    呵呵。有一个方法就是将二进制文件转换成16进制字符串。到收到再转换成二进制。不过如果是二进制的。我建议先压缩成ZIP再转成字符串。这样好点。不过要点处理时间。
      

  2.   

    一定要用xml吗,干吗不用access,它可以存取图片的。
      

  3.   

    我做过了。你可以用base64编码,用CDATA存进去就是。
      

  4.   

    我认为xml是一种标记语言,如果用它来存放二进制的数据,就失去了作为标记语言的主要作用,倒不如在xml中存放图片的路径。
      

  5.   

    dim st,xmldoc,iPic
    set st = CreateObject("adodb.stream")
    st.Type=1
    st.Open
    st.loadFromFile "F:\index_a0b1.gif"'你要转换的图片
    set xmldoc = CreateObject("Microsoft.XMLDOM")
    xmldoc.loadXML "<?xml version=""1.0""?><root/>"
    set iPic = xmldoc.createElement("pic")
    iPic.dataType = "bin.base64"
    iPic.nodeTypedValue = st.Read(-1)
    xmldoc.documentElement.appendChild iPic
    xmldoc.save App.Path & "pic.xml"
      

  6.   

    标准exe,一个PictureBox控件
    Private Sub Form_Load()
        Dim xmldoc As Object
        Set xmldoc = CreateObject("Microsoft.XMLDOM")
        xmldoc.async = False
        xmldoc.Load "F:\http\formo\club\image.xml"
        If xmldoc.parseError.errorCode Then
            MsgBox "loading error!"
        Else
            Dim temp_image() As Byte
            Dim temp_file As String
            Dim a
            Set a = xmldoc.documentElement.selectSingleNode("pic")
            If TypeName(a) = "Nothing" Then
                MsgBox "节点不存在!"
            Else
                temp_image() = a.nodeTypedValue
                temp_file = App.Path & "temp.gif"
                Open temp_file For Binary As #1
                Put #1, , temp_image()
                Close #1
                Picture1.Picture = LoadPicture(temp_file)
                Kill temp_file
            End If
        End If
    End Sub