View Single Post
Old Nov 17th, 2006, 9:11 AM   #3
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 237
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
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
xml Syntax (Toggle Plain Text)
  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>


vbnet Syntax (Toggle Plain Text)
  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
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt

Last edited by melbolt; Nov 17th, 2006 at 10:09 AM.
melbolt is offline   Reply With Quote