View Single Post
  #1 (permalink)  
Old February 12th, 2010, 05:18 PM
Lennie Lennie is offline
Authorized User
Points: 97, Level: 1
Points: 97, Level: 1 Points: 97, Level: 1 Points: 97, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Feb 2010
Location: New Zealand
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
Default Vb.Net 2003 : How to Open and Read an XML File to TEXT File.

Hi Good Guys,
I have another interest problem. I need your help. Thank you in advance.

I have created 2 format types (ELEMENT, ATTRIBUTE) of XML File. To open and read the ELEMENT Format type
and write the row into TEXT string for display is fine but the ATTRIBUTE Format is not working.
The problem is how to identify the format type at runtime in order to develop the script.

The scripts below works on ELEMENT format and not on ATTRIBUTE format type :
How to identify the Format type ?

Imports System.Xml
Imports System.IO
Imports System.Data
Imports System.Text

 Private Function FReadXMLFile()
        Dim xmlDoc As New XmlDataDocument
        Dim xmlNode As XmlNodeList
        Dim intNode As Integer = 0
        Dim x As Integer = 0
        Dim i As Integer = 0

        Dim strText As String   ' use for display
        Dim fs As New FileStream(Me.txtFileName.Text, FileMode.Open, FileAccess.Read)

        Dim intRowCnt As Integer = xmlDoc.GetElementsByTagName("row").Count
        xmlNode = xmlDoc.GetElementsByTagName("row")
        For x = 0 To (intRowCnt - 2)
            i = 0
            For i = 0 To (xmlNode.Count - 3)
                strText &= xmlNode(x).ChildNodes(i).InnerText.Trim & "|"
                If i = (xmlNode.Count - 3) Then
                    strText &= ControlChars.NewLine
                End If
End Function

Thank you very much.

Have a good day.

Reply With Quote