Parse an xml stream

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2009
Posts: 7
Reputation: smileyc is an unknown quantity at this point 
Solved Threads: 0
smileyc smileyc is offline Offline
Newbie Poster

Parse an xml stream

 
0
  #1
Jul 6th, 2009
Hi. using the following code I am trying to read an xml stream
[code]
  1. Do While (reader.Read())
  2. Select Case reader.NodeType
  3.  
  4. Case XmlNodeType.Element 'Display beginning of element.
  5.  
  6. MsgBox("<" + reader.Name)
  7.  
  8. Case XmlNodeType.Text 'Display the text in each element.
  9. MsgBox(reader.Value)
  10. Case XmlNodeType.EndElement 'Display end of element.
  11. MsgBox("</" + reader.Name + ">")
  12. ' MsgBox(">")
  13. Case XmlNodeType.Attribute
  14. MsgBox(reader.Value)
  15. Case XmlNodeType.EntityReference
  16. MsgBox(reader.Value)
  17. Case XmlNodeType.EndElement
  18. MsgBox("At end element" + reader.Value)
  19. Case XmlNodeType.Comment
  20. MsgBox(reader.Value)
  21. Case XmlNodeType.SignificantWhitespace
  22. MsgBox("SignificantWhitespace")
  23. Case XmlNodeType.Whitespace
  24. MsgBox("Whitespace")
  25. Case XmlNodeType.ProcessingInstruction
  26. MsgBox(reader.Value)
  27. End Select
  28. Loop
  29. [/ code]

If the element is wholly between the tags such as
  1. <book>MOBY DICK</book>
Then the msgbox displays the title of the book.
If as in the case below there is a whitespace in the element name t
  1. <book title ="MOBY DICK" value="Not Available"/>
Then the code simpley selects the 'whitespace' case and does not go on to parse the rest of the element line.

So my question is, using vb.net how can I read the elements and associated values in such an xml schema? I best state that all this is v new to me, so if I have used any inccorrect terms in describing my problem I apologise and hope that such does render the description of my problem unintelligible. THanks for all and any help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC