p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VS.NET 2002/2003 (http://p2p.wrox.com/forumdisplay.php?f=103)
-   -   Vb.Net 2003 : How to Open and Read an XML File to TEXT File. (http://p2p.wrox.com/showthread.php?t=78170)

Lennie February 12th, 2010 05:18 PM

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 ?


---------------------------------------------------------
Code:

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)

        xmlDoc.Load(fs)
        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
            Next
        Next
 
        MessageBox.Show(strText)
End Function



All times are GMT -4. The time now is 04:23 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.