首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

VB6.0 生成XML时,怎么设置版本号,字符集

2012-02-07 
VB6.0 生成XML时,如何设置版本号,字符集?各位:对VB6编程不是很熟,在网上找过很多地方,都没找到如何像.NET

VB6.0 生成XML时,如何设置版本号,字符集?
各位:
  对VB6编程不是很熟,在网上找过很多地方,都没找到如何像.NET那样设置版本号与字符集的方法。 xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", String.Empty)
  请大家帮个忙,最好给一整段代码的例子。
  多谢。

[解决办法]

VB code
Set xXMLpi = Doc.createProcessingInstruction("xml", "version='1.0' encoding='utf-8'")
[解决办法]
下面函数是我Socket传输序列化查询结果集用的、
VB code
Public Function CreateXMLString(ByVal strSql As String, ByRef lngLenght As Long) As String    Dim strPath As String    Dim lngRecordLine As Long    Dim xmlDoc As DOMDocument    Dim xmlRoot As IXMLDOMElement    Dim xmlEle As IXMLDOMElement    Dim xmlNode As IXMLDOMNode    Dim xmlChildNode As IXMLDOMNode    Dim nFieldCount As Long    Dim rs As ADODB.Recordset    Dim i As Integer        Dim strRecord As String        lngRecordLine = 0        On Error GoTo ms    Set xmlDoc = New DOMDocument    Set xmlNode = xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding='gb2312'")    Set xmlNode = xmlDoc.insertBefore(xmlNode, xmlNode.childNodes.Item(0))        Set xmlRoot = xmlDoc.createElement("RecordData")    Set xmlDoc.documentElement = xmlRoot         lngRecordLine = 1    Set rs = New ADODB.Recordset        Set rs = ExecuteSQL(strSql)    nFieldCount = rs.Fields.Count    Do Until rs.EOF        Set xmlEle = xmlDoc.createElement("Record" & lngRecordLine)        xmlRoot.appendChild xmlEle        strRecord = ""        For i = 1 To nFieldCount            xmlEle.setAttribute rs.Fields(i - 1).Name, rs.Fields(i - 1).value        Next i        lngRecordLine = lngRecordLine + 1        rs.MoveNext    Loop    rs.Close        CreateXMLString = xmlDoc.xml    lngLenght = Len(CreateXMLString)        Set xmlChildNode = Nothing    Set xmlNode = Nothing    Set xmlEle = Nothing    Set xmlRoot = Nothing    Set xmlDoc = Nothing        Exit Functionms:    End Function 

热点排行