XML & VB6.0
-
Dear all I am having xml file that look as below ABC 16 XYZ 26 AAA 26 Now i want to read every name and age from the xml file. The code used as Dim XMLDoc As New DOMDocument30 Dim NodLst As IXMLDOMNodeList Dim Node As IXMLDOMNode Dim Nod As IXMLDOMNode Dim nodCnt As Long Dim Data() As String XMLDoc.async = False 'Loading the XML file on C drive If XMLDoc.Load("D:\XML\123.xml") Then '========================== 'Assigning root node to the node list variable Set NodLst = XMLDoc.selectNodes("/People") ReDim Data(NodLst.length) For nodCnt = 0 To NodLst.length - 1 Set Nod = NodLst(nodCnt).selectSingleNode("Person") Data(nodCnt) = Nod.Text Set Nod = NodLst(nodCnt).childNodes(0) '=========================== 'Appending data inside "from" to "to" Data(nodCnt) = Data(nodCnt) & vbTab & Nod.Text Text1.Text = nodCnt Text3.Text = Data(nodCnt) Next nodCnt Else MsgBox ("Can't load file") End If The result is ABC () 16 where as i need Name="ABC" & Age="16" Please help Thanx in advance...!!! Shazz here to help you...
-
Dear all I am having xml file that look as below ABC 16 XYZ 26 AAA 26 Now i want to read every name and age from the xml file. The code used as Dim XMLDoc As New DOMDocument30 Dim NodLst As IXMLDOMNodeList Dim Node As IXMLDOMNode Dim Nod As IXMLDOMNode Dim nodCnt As Long Dim Data() As String XMLDoc.async = False 'Loading the XML file on C drive If XMLDoc.Load("D:\XML\123.xml") Then '========================== 'Assigning root node to the node list variable Set NodLst = XMLDoc.selectNodes("/People") ReDim Data(NodLst.length) For nodCnt = 0 To NodLst.length - 1 Set Nod = NodLst(nodCnt).selectSingleNode("Person") Data(nodCnt) = Nod.Text Set Nod = NodLst(nodCnt).childNodes(0) '=========================== 'Appending data inside "from" to "to" Data(nodCnt) = Data(nodCnt) & vbTab & Nod.Text Text1.Text = nodCnt Text3.Text = Data(nodCnt) Next nodCnt Else MsgBox ("Can't load file") End If The result is ABC () 16 where as i need Name="ABC" & Age="16" Please help Thanx in advance...!!! Shazz here to help you...
It appears that you're relying on the Nod.Text property to format the field names and values for you. Don't. Just get the Name and Age values for each person and format the output string yourself.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008