473,387 Members | 3,820 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.

Problem writing to an XML file

I have added an XML file to my project and set it up like so:

<rotas xmlns = "http:\\ etc..">
<Managers>
<manager ID = "1" FirstName = "Bill" LastName = "Gates"<\manager>
<\Managers>
<\rotas>

Now, when I add a new manager row to this table called Managers, it doesn't
appear between the <Managers> tags, but instead it appears just below it. I
then have difficulty in deleting a new file as it can't be found, probably
due to this error.

The syntax I am using to add a new manager row is:

DataRow row = rotas1.manager.NewRow();
string [] ar = new string [3] {txtID.Text, txtFirstName.Text,
txtLastName.Text};

for(int i = o; i<ar.Length; i++)
{
row[i] = ar[i];
}
rotas1.manager.Rows.Add(row);
rotas1.WriteXml("..\\..\\XMLFile1.xml");

Can anyone please point me in the right direction.
Nov 16 '05 #1
1 1042
You need to associate the poor orphan with it's parent. Try this
before you add the row:
row.ManagersRow=rotas1.Managers[0];

Or, even better, just use this line:
rotas1.manager.AddmanagerRow(
txtID.Text, txtFirstName.Text, txtLastName.Text,
rotas1.Managers[0]
);

Peace,
Brett

cashdeskmac wrote:
I have added an XML file to my project and set it up like so:

<rotas xmlns = "http:\\ etc..">
<Managers>
<manager ID = "1" FirstName = "Bill" LastName = "Gates"<\manager> <\Managers>
<\rotas>

Now, when I add a new manager row to this table called Managers, it doesn't appear between the <Managers> tags, but instead it appears just below it. I then have difficulty in deleting a new file as it can't be found, probably due to this error.

The syntax I am using to add a new manager row is:

DataRow row = rotas1.manager.NewRow();
string [] ar = new string [3] {txtID.Text, txtFirstName.Text,
txtLastName.Text};

for(int i = o; i<ar.Length; i++)
{
row[i] = ar[i];
}
rotas1.manager.Rows.Add(row);
rotas1.WriteXml("..\\..\\XMLFile1.xml");

Can anyone please point me in the right direction.


Nov 16 '05 #2

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

Similar topics

2
by: Randy Jackson | last post by:
Hello all. Okay, this seems really stupid, but it's driving me up the wall. I have a simple script I've written to log some information to a text file. Everything seems to be okay, the code...
2
by: Pierre Rouleau | last post by:
Hi all! I'm trying to extend the functionality of the file object by creating a class that derives from file. MyFile class re-implements __init__(), write(), writelines() and close() to augment...
8
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out |...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
0
by: deacon57 | last post by:
FYI - If you are a computer scientist (or geek), this post may be for you. I wanted to log any search keywords, etc that are used on my site. I created a simple program that logs search terms...
2
by: Thelonious Monk | last post by:
I have a problem where some data is being eliminated. The problem is that the data contains signed numeric fields (the low-order byte of a negative number uses the first 4 bits as a sign and...
10
by: Rahul | last post by:
Friends, My Problem is related to writing a text file from a database using .Net. in a particular string format. I have a dataset with a table, let suppose in this table there are three fields....
5
by: Neil Crighton | last post by:
I'm using the zipfile library to read a zip file in Windows, and it seems to be adding too many newlines to extracted files. I've found that for extracted text-encoded files, removing all instances...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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...

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.