Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   help in reading XML (http://www.programmingforums.org/showthread.php?t=11915)

nascar2000 Nov 17th, 2006 6:00 AM

help in reading XML
 
hello everybody, i need help in reading a XML file , can somebody teach me how to read from a xml file within visual basic frame.

alphonso Nov 17th, 2006 7:27 AM

You might wanna start reading here

melbolt Nov 17th, 2006 10:11 AM

here is an example from one of my programs where i read xml from a file and puts the data into an array. The xml contains a bunch of random phrases.

here's an example of what my Phrases.xml file looks like
:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <phrases>
  3.   <phrase>phrase 1</phrase>
  4.   <phrase>phrase 2</phrase>
  5.   <phrase>phrase 3</phrase>
  6.   <phrase>phrase 4</phrase>
  7. </phrases>



:

  1.         Dim PhraseArray(500) As String
  2.         Dim MyXmlTextReader As New XmlTextReader("S:\ApplicationPool\CIMS Talker\Phrases.xml")
  3.         Dim i As Integer = 0
  4.         MyXmlTextReader.WhitespaceHandling = WhitespaceHandling.None
  5.  
  6.         'initial read to get past xml declaration
  7.         MyXmlTextReader.Read()
  8.  
  9.         While MyXmlTextReader.Read()
  10.             If MyXmlTextReader.Value.Length > 0 Then
  11.                 PhraseArray(i) = MyXmlTextReader.Value
  12.                 i = i + 1
  13.             End If
  14.         End While
  15.  
  16.         MyXmlTextReader.Close()



much like using a sqldatareader, everytime you call .Read() it retrieves the next value.

btw import system.xml


All times are GMT -5. The time now is 1:32 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC