473,387 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Parsing XML Data Part II

I seem to still be stuck a bit on getting started with XMLTextReader which
seem to be exactly what I need. I retrieve a fragment of data from a
database field, an example of which is (I have no control over how it is
formatted or structured):

<qMultipleChoice>
<qText>What workstation are you working at?</qText>
<qChoice>1</qChoice>
<qChoice>2</qChoice>
<qChoice>3</qChoice>
<qChoice>4</qChoice>
<qChoice>5</qChoice>
<qChoice>7</qChoice>
<qChoice>8</qChoice>
<qChoice>9</qChoice>
<qChoice>Other</qChoice>
</qMultipleChoice>

I can loop through it using the XMLTextReader and see the names of the
elements with reader.Name, getting

qMultipleChoice
qText
qChoice
qChoice......etc.

However I can not get the values. reader.value seems to return nothing. I
need to get the name of each element and the values and take certain
formatting and structure actions based on the names. I tried
reader.ReadElementString, but then I can not apparently see what the name
is. Can anyone loan me a clue-by-4 on how to get the value and names? I know
I am missing something.

Kent
Nov 20 '05 #1
1 906

"Kent Ogletree" <ke**@nospam.actionic.com> wrote in message
news:e%****************@tk2msftngp13.phx.gbl...
I seem to still be stuck a bit on getting started with XMLTextReader which
seem to be exactly what I need. I retrieve a fragment of data from a
database field, an example of which is (I have no control over how it is
formatted or structured):

<qMultipleChoice>
<qText>What workstation are you working at?</qText>
<qChoice>1</qChoice>
<qChoice>2</qChoice>
<qChoice>3</qChoice>
<qChoice>4</qChoice>
<qChoice>5</qChoice>
<qChoice>7</qChoice>
<qChoice>8</qChoice>
<qChoice>9</qChoice>
<qChoice>Other</qChoice>
</qMultipleChoice>

I can loop through it using the XMLTextReader and see the names of the
elements with reader.Name, getting

qMultipleChoice
qText
qChoice
qChoice......etc.


Try this:
Sub main()
Dim xr As XmlTextReader = New XmlTextReader("choice.xml")
xr.WhitespaceHandling = WhitespaceHandling.None
xr.Read()
Console.WriteLine(xr.Name)
xr.ReadStartElement()
While xr.IsStartElement
Console.WriteLine(xr.Name & " - " & xr.ReadElementString)
End While
xr.ReadEndElement()
xr.Close()
end sub

David
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nick Webster | last post by:
Hi, I have a slight problem with parsing XML: If the tag was say - <Something ID="12"> - My parser is only retrieving the 'Something' part, and discarding the 'ID="12"'. Code: function...
8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
3
by: dont bother | last post by:
Hey, I have been trying to parse emails: But I could not find any examples or snippets of parsing emails in python from the documentation. Google did not help me much too. I am trying to...
5
by: Rafal 'Raf256' Maj | last post by:
Hi, I need to parse a file. This means reading from it as from std::istream. But - sometimes I also need to put-back some text I read before. What type of string can I use for that? Something...
1
by: yonido | last post by:
hello, my goal is to get patterns out of email files - say "message forwarding" patterns (message forwarded from: xx to: yy subject: zz) now lets say there are tons of these patterns (by gmail,...
6
by: Tuomas Rannikko | last post by:
Hello, I'm currently writing a XML processor for the fun of it. There is something I don't understand in the spec though. I'm obviously missing something important. The spec states that both...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
1
by: Thomas Kowalski | last post by:
Hi, I have to parse a plain, ascii text file (on local HD). Since the file might be many millions lines long I want to improve the efficiency of my parsing process. The resulting data structure...
3
by: Cuong.Tong | last post by:
Greeting, I am writing my own web server and having some problme parsing the the mulitpart/form-data stream that is sent from the browsers. I have a form looks something like this <form...
2
by: RG | last post by:
I am having trouble parsing the data I need from a Serial Port Buffer. I am sending info to a microcontroller that is being echoed back that I need to remove before I start the actual important...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.