Hello,
Firstly, I wish to thank the dedicated professionals on this site who assist us, the newbies. I'm now an intermediate programmer and some of the professionals on this site has assisted me by answering few of the questions that I have posted.
Now I have an issue where I wish to get the tags together with the elements from an xml file onto a text file. The following is the xml file details and its intended output.
="1.0"
<Cheque_Deposit_Transactoin>
<Transaction_Date>17/04/14</Transaction_Date>
<Transaction_Time>11:07</Transaction_Time>
<Transaction_Sequence_Number>0124</Transaction_Sequence_Number>
<Total_Cheque_Deposit_Amount>2000.00</Total_Cheque_Deposit_Amount>
<Card_Number>601302....5796</Card_Number>
<Account_Number>001013039738</Account_Number>
<Cheques><Cheque index="1">
<MICR>*1056145* 030-500T 0002003456*</MICR>
<Cheque_Serial_Number>105614</Cheque_Serial_Number>
<Cheque_Scanned_Amount>200000</Cheque_Scanned_Amount>
<Cheque_Disposition>1</Cheque_Disposition>
</Cheque></Cheques>
</Cheque_Deposit_Transactoin>
Output that I wish to get from the above is as follows:
Cheque_Deposit_Transactoin
Transaction_Date:17/04/14
Transaction_Time:11:07
Transaction_Sequence_Number:0124
Total_Cheque_Deposit_Amount:2000.00
Card_Number:601302....5796
Account_Number:001013039738
Cheques
MICR:*1056145* 030-500T 0002003456
Cheque_Serial_Number:105614
Cheque_Scanned_Amount:200000
Please assist. I have actually managed to get the elements using the following code but I also would like to get the tags together and get the result onto a text file.
Dim xmldoc As New XmlDataDocument()
Dim xmlnode As XmlNodeList
Dim i As Integer
Dim x As Integer
Dim str As String
Dim fs As New FileStream("Test.xml", FileMode.Open, FileAccess.Read)
xmldoc.Load(fs)
xmlnode = xmldoc.GetElementsByTagName("Cheque_Deposit_Transactoin")
For i = 0 To xmlnode.Count - 1
For x = 0 To xmlnode(i).ChildNodes.Count - 1
xmlnode(i).ChildNodes.Item(0).InnerText.Trim()
str = xmlnode(i).ChildNodes.Item(x).InnerText.Trim()
MsgBox(str)
x = ++x
Next
Next