473,385 Members | 2,269 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,385 software developers and data experts.

Reading XML String, Parsing Data -- Strange Behavior

Ron

I have a method that generates an string in XML format and passes it to be
processed. The string is in the following format:

<grandparent>
<parent>
<child1>text</child1>
<child2>text again</child2>
</parent>
<aunt>
<cousin1>text</cousin1>
<cousin2>text2</cousin2>
<cousin3>text4</cousin3>
</aunt>
</grandparent>

string xmlInput = <values above>
XPathDocument xpDoc = new XPathDocument(new StringReader(xmlInput));
XPathNavigator xpNav = xpDoc.CreateNavigator();

//move to root element <grandparent>
xpNav.MoveToRoot();
xpNav.MoveToFirstChild(); //move to <parent>
xpNav.MoveToFirstChild(); //move to <child1>
strChild1 = xpNav.Value;
xpNav.MoveToNext(); //move to <child2>
strChild2 = xpNav.Value;
.....

The problem I am having is that the xpNav.Value keeps concatenating every
other value onto itself. So instead of having:
strChild1 = "text";
and
strChild2 = "text again";
as I expect, I am getting the following:
strChild1 = "texttextagain";, etc.

Can anyone give me any ideas as to what I am doing wrong and how I might be
able to fix it?

Thanks for your help,

Ron
--
--------------------------------------------------------------
Ron Rodenberg
Lead Software Engineer
Razorvision Technology
8080 N. Central Expressway
Suite 400
Dallas, TX 75206
Nov 15 '05 #1
0 1164

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

Similar topics

3
by: anon | last post by:
So I've encountered a strange behavior that I'm hoping someone can fill me in on. i've written a simple handler that works with one small exception, when the parser encounters a line with '&' in...
11
by: Matt DeFoor | last post by:
I have some log files that I'm working with that look like this: 1000000000 3456 1234 1000000001 3456 1235 1000020002 3456 1223 1000203044 3456 986 etc. I'm trying to read the file...
1
by: john | last post by:
Relatively new to C coding, so any help would greatly be appreciated. I'm having problems try to return my string array from my parsing function. When I do a printf I am getting the correct value...
2
by: Chuck Ritzke | last post by:
Hi all, I am getting an intermittant error after uploading a project from my development machine. I click on a link which opens an aspx page that, upon page load, reads a very small amount of...
5
by: Jesse Albert | last post by:
Hiyo, I'm trying to import a CSV file into a datatable using either ODBC or OLEDB. One of the columns contains an IP Address. For some reason, the IP address will not display correctly. All of...
3
by: Brad | last post by:
I'm having a problem reading data from an Excel file into a dataset. Can anybody give me an idea of what's happening? I've included the problematic source and the error message to the end of this...
111
by: Tonio Cartonio | last post by:
I have to read characters from stdin and save them in a string. The problem is that I don't know how much characters will be read. Francesco -- ------------------------------------- ...
2
by: Rob111b | last post by:
Hi there, I need to make a piece of code in C that 1. opens a specified file, 2. Reads the data in the file and separates it as shown below, 3. Converts the strings into integers and then...
4
by: Mastastealth | last post by:
I'm trying to create a program to read a certain binary format. I have the format's spec which goes something like: First 6 bytes: String Next 4 bytes: 3 digit number and a blank byte --- Next...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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,...

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.