473,787 Members | 2,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Reading XML file using XMLTextReader


My XML file
<FORMLIST>
<InsuredInfo>
<ANO>SR750123 4</ANO>
<ADATE>02/05/2007</ADATE>
<InsName>SIRO NA DENTAL SYSTEMS INC</InsName>
<POLNO>DOL75012 34</POLNO>
<PEDATE>03/01/2007</PEDATE>
<PXDATE>03/01/2008</PXDATE>
<RevDATE></RevDATE>
<UndName>CAL</UndName>
</InsuredInfo>
<FORM>
<FORMNAME>A2007 2.002</FORMNAME>
<FORMTABLE>tblM ergeMQ_PRNT</FORMTABLE>
<RECORDID>1</RECORDID>
<COUNTERSIGN> 1</COUNTERSIGN>
</FORM>
<FORM>
<FORMNAME>A2007 2.002</FORMNAME>
<FORMTABLE>tblM ergeMQ_PRNT</FORMTABLE>
<RECORDID>1</RECORDID>
<COUNTERSIGN> 1</COUNTERSIGN>
</FORM>
<END>
<ENDNAME>D02419 .000</ENDNAME>
<BLANKS>3</BLANKS>
<SPECIMEN>0</SPECIMEN>
<BLANKDATA>
<BLANK1>50,00 0</BLANK1>
<BLANK2>30,00 0</BLANK2>
<BLANK3>60,00 0</BLANK3>

</BLANKDATA>
</END>
<END>

</END>
</FORMLIST>

'Here is my current code

Private Sub ReadXml()

Dim objSettings As New XmlReaderSettin gs
objSettings.Ign oreWhitespace = True
objSettings.Ign oreComments = True

Dim objXMLReader As XmlReader = XmlReader.Creat e("X:\FormsMail Merge
\ProcessEndorse ments\ProcessEn dorsements\Form List.xml", objSettings)
Try

'objXMLReader.R eadToDescendant ("FORM")

Do While objXMLReader.Re ad()
If (objXMLReader.N ame = "InsuredInf o" And
objXMLReader.No deType = XmlNodeType.Ele ment) Then

objXMLReader.Re ad()
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
ElseIf (objXMLReader.N ame = "FORM" And objXMLReader.No deType =
XmlNodeType.Ele ment) Then
objXMLReader.Re ad()
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
ElseIf (objXMLReader.N ame = "END" And objXMLReader.No deType =
XmlNodeType.Ele ment) Then
objXMLReader.Re ad()
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)
Debug.WriteLine (objXMLReader.R eadElementConte ntAsString)

End If
Loop
Catch ex As Exception

Finally
objXMLReader.Cl ose()
End Try

End Sub

Question is <BLANKDATA element can have different number of nodes.
How do I iterate through those noes (i.e. Blank1 , Blank2 etc.)
<BLANKDATA>
<BLANK1>50,00 0</BLANK1>
<BLANK2>30,00 0</BLANK2>
<BLANK3>60,00 0</BLANK3>
......
.....
</BLANKDATA>

Any suggestion on improving my code? Thanks in advance

Feb 13 '07 #1
0 2398

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

Similar topics

3
4224
by: keldan | last post by:
I am hoping someone on this list can shed some light on the below issue for me. I am using XmlTextReader to read from an XML file. Unfortunately, an exception is thrown ("Index was outside the bounds of the array.") when the reader reaches the DOCTYPE. If I remove it everything works fine. Should I be handling the DOCTYPE someway before I read the DOCTYPE? Any insight would be greatly appreciated. I have provided a sample XML...
4
5549
by: Drew | last post by:
I'm reading in an XML file from the server using XmlTextReader in C# like so: XmlTextReader xr = new XmlTextReader(url); while(xr.Read()) { //parse the xml file here
1
1572
by: Damon Allison | last post by:
Hello, My program is being sent a large XML file, anywhere between 500k - 1MB. Of the entire file, I need to allow a user to view/edit approximately 5% of it. To make matters a bit more complicated, there are occasions where the program needs to load up around 5 instances of these documents. I'm trying to find the most efficient and non-complicated way to do this. My initial idea was to load the XML file into a DOM and get/set the...
4
1571
by: Oliver Sturm | last post by:
I have an XML file that contains fragments, meaning there's no root element. Node names are in my own "test" namespace. Looks like this: <test:info date="...">Content</test:info> <test:info date="...">Other content</test:info> .... I have some .net 1.1 code that reads the nodes from the file one by one: FileStream stream = new FileStream(@"file.xml", FileMode.Open);
1
3444
by: Chua Wen Ching | last post by:
Hi there, I have some problems when reading XML file. 1. First this, is what i did, cause i can't seem to read "sub elements or tags" values, so i place those values into attributes like this. Before: ----------
1
1086
by: adhag | last post by:
Hi I have an app that uses xpath to read an xml document. The problem is a 70meg file uses 1.5 gig of memory. What I really need is to read only chunks of the file at a given time and cannot afford the overhead of reading in 1.5 gig of memory. A simplified example would be an xml file of 100 rows that I wanted to return random chunks of records without reading in all 100 rows each time. I would have a row number and a set number of...
6
1513
by: Lloyd Dupont | last post by:
I have some XML file like that: === <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>affiliateId</key> <string>AFL9124395098</string>
3
3610
by: Yehia A.Salam | last post by:
Hello, I am trying to read from an xml file and put it to a memory stream so I can read it multiple times from the beginning using XmlTextReader without accessing the harddisk , I tried using FileStream but it locked the xml file so I can't access it anymore until I close the filestream, so my question is how to read from the file to the memorystream directly or read to the filestream first and the copy it to the memorystream? Thanks
13
3279
by: Rick | last post by:
The following code will enter an infinate loop when in ReadChars. I can only make it happen when reading a Stream and with this particular XML. If I use the ReadInnerXml call rather than my own ReadElementBodyAsXml the code works, but is less efficent. ReadElementBodyAsXml is required by my application with .Net Framework 1.1. The code breaks on the second call to ReadElementBodyAsXml with the inner xml: </EGDConfigExtension>...
16
2599
by: billsahiker | last post by:
I am researching for an upcoming c# .net 2.0 project that may require reading and writing xml files. I don't want to use xmltextreader/ xmltextwriter as I prefer to have lower level file access and more control, and a smaller memory footprint, and I wont need most of their functionality. I do need to handle utf8 and utf16 encodings and I need to insert some tags. Should I use the streamreader/streamwriter classes and the encoding
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.