473,395 Members | 1,474 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,395 software developers and data experts.

Read & Write to XML

Hi,

i like to read an existing xml file which has a schema defined to it, and
then write or add data to the existing xml file using vb.net/c#.

May be this Question has been answered earlier.
Pls if anyone knows the link or example let me know

Thanks
ARvind.

Nov 20 '05 #1
5 1995
"Arvind P Rangan" <ar******@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
Hi,

i like to read an existing xml file which has a schema defined to it, and
then write or add data to the existing xml file using vb.net/c#.


Try asking this question in the XML group, you will get a better response:

microsoft.public.dotnet.xml

Also see the XML namespace in the .NET Docs, there are several functional
eamples of how to do exactly what you want.
HTH,
Jeremy

Nov 20 '05 #2
Cor
Hi Jeremy,
i like to read an existing xml file which has a schema defined to it, and
then write or add data to the existing xml file using vb.net/c#.

Maybe it is clever to read the full question before you send such an answer.

The question is I think a full example in vb.net language code for handling
a XML file as a dataset or whatever without writing it back as a stream.

In my opinion that is not posible but I was waiting if someone could give a
better answer than me.

And because of an earlier help I could give to Arvin this morning and the
way he did give response to me, he probably knows that already and is
searching if there is something more sophisticated method.

He did has placed the same question at 13:00 GMT in the xml.dotnet. group

Cor
Nov 20 '05 #3
Hi Cor,
Thanks Cor
As u have mentioned i have placed the msg on Xml group and no reply till
date.
Other than someone asking me to check in archives.

I have a example given by Raju, but that does read and write a XML file but
creates a new note called <NEWDATASET> above the current RootDocument Node.

Which i don't i want the existing Schema to remain as it is.
Thanks
I can give u the Example given try it Out.
XML READ N WRITE.,
'Sample code in VB.NET

Dim ds As DataSet
ds = New DataSet
ds.ReadXmlSchema(Server.MapPath("XmlFile1.xsd"))
ds.ReadXml(Server.MapPath("XmlFile1.xml"))
Dim dv As DataView = New DataView(ds.Tables("Order"))
Dim dr As DataRowView = dv.AddNew()
dr("orderID") = "3"
dr("customerID") = "3"
dr.EndEdit()
ds.AcceptChanges()
ds.WriteXml(Server.MapPath("XmlFile1.xml"))

This does add new node.
Check it out.
Thanks
aRvind.

"Cor" <no*@non.com> wrote in message
news:3f***********************@reader21.wxs.nl...
Hi Jeremy,
i like to read an existing xml file which has a schema defined to it, and then write or add data to the existing xml file using vb.net/c#.
Maybe it is clever to read the full question before you send such an

answer.
The question is I think a full example in vb.net language code for handling a XML file as a dataset or whatever without writing it back as a stream.

In my opinion that is not posible but I was waiting if someone could give a better answer than me.

And because of an earlier help I could give to Arvin this morning and the
way he did give response to me, he probably knows that already and is
searching if there is something more sophisticated method.

He did has placed the same question at 13:00 GMT in the xml.dotnet. group

Cor

Nov 20 '05 #4
Hi Arvind,

You may be able to achieve what you want (without going anywhere near a
DataSet) by using the XmlDocument. But it depends...

What does your Xml look like and what do you want to add to it? And any
other info that might be useful...

Regards,
Fergus
Nov 20 '05 #5
Cor
Hi Arvind,
I have used that too, but I am also curious if that is the best way to do
it.

And to think about, do you really need the schema?

I did in my solution at a moment skip the schema without any problem.
What is good when you use that is first saving the original xml file before
you write it.
Because when there is an error while writing you loose all.

And to make it more complet of course I would put the reading and writing in
some
try
catch
end try

blocks

Cor

Dim ds As DataSet
ds = New DataSet
ds.ReadXmlSchema(Server.MapPath("XmlFile1.xsd"))
ds.ReadXml(Server.MapPath("XmlFile1.xml"))
Dim dv As DataView = New DataView(ds.Tables("Order"))
Dim dr As DataRowView = dv.AddNew()
dr("orderID") = "3"
dr("customerID") = "3"
dr.EndEdit()
ds.AcceptChanges()
ds.WriteXml(Server.MapPath("XmlFile1.xml"))

Nov 20 '05 #6

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
9
by: Collin VanDyck | last post by:
I have a basic understanding of this, so forgive me if I am overly simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric character...
0
by: Abubakar | last post by:
Hi, try { int x = ns.Read(readbuffer, 0, readbuffer.Length); } catch (System.IO.IOException ioexception) { UINotifications.ServerMessageDisplay(ioexception.ToString( )); }
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
6
by: cj | last post by:
I'm receiving an xml formatted string that I pull data from by reading it into an xml document like this: Dim doc As New Xml.XmlDocument doc.LoadXml(respstr) Dim co_name As Xml.XmlNodeList =...
0
by: rchadda | last post by:
I haven't started using Seqouia/C-jdbc but I am probing the ability to do something like this: Controller CW has 2 controllers under it - C1 & C2. C1 is local and has a host HA with X.db's...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
0
by: magicbeans | last post by:
I am trying to create a .bin file of records from a .txt file. Initially the records are stored in a text file and I want to Read from the .txt file and Write to the .bin file. This is the C++...
2
by: Bina | last post by:
hi, I want to read & write a html file which contain the japanese character. Now how i will do it?I can read & write english character . but when i read & write Japanese character from the html...
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:
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,...
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.