473,549 Members | 2,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2017
"Arvind P Rangan" <ar******@hotma il.com> wrote in message
news:er******** ******@TK2MSFTN GP12.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.publi c.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.ReadXmlSchem a(Server.MapPat h("XmlFile1.xsd "))
ds.ReadXml(Serv er.MapPath("Xml File1.xml"))
Dim dv As DataView = New DataView(ds.Tab les("Order"))
Dim dr As DataRowView = dv.AddNew()
dr("orderID") = "3"
dr("customerID" ) = "3"
dr.EndEdit()
ds.AcceptChange s()
ds.WriteXml(Ser ver.MapPath("Xm lFile1.xml"))

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

"Cor" <no*@non.com> wrote in message
news:3f******** *************** @reader21.wxs.n l...
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.ReadXmlSchem a(Server.MapPat h("XmlFile1.xsd "))
ds.ReadXml(Serv er.MapPath("Xml File1.xml"))
Dim dv As DataView = New DataView(ds.Tab les("Order"))
Dim dr As DataRowView = dv.AddNew()
dr("orderID") = "3"
dr("customerID" ) = "3"
dr.EndEdit()
ds.AcceptChange s()
ds.WriteXml(Ser ver.MapPath("Xm lFile1.xml"))

Nov 20 '05 #6

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

Similar topics

1
6813
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 elements, attributes, ".", and "..", plus also the "" predicate format is supported - however, only one predicate per path step is supported, and expr must...
9
8531
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 reference (i.e.  ) and it seems to be converting the character to its UNICODE representation. Take this source XML document: <?xml version="1.0"...
0
1525
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
2790
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);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as...
6
2235
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 = doc.GetElementsByTagName("co_name") textbox1.text = co_name(0).innertext Now I'm getting company names that have ampersands in them. I was not...
0
1156
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 tables t1 & t2. C2 is remote and has a host HB also with X.db's tables t1 & t2. Controller CR has 2 controllers under it - C3 & C4. C3 is local and...
14
5914
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 because of this, so I hope some of you gurus can enlighten me with this :) In what circumstances can the "&amp;" in the source code be involuntary...
0
1888
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++ code. The result write exactly but it has funny-looking unwanted characters attached at the end of the .bin file. How do I fix it? #include...
2
7692
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 file then the writed html file cannnot show the japanese character. my new created html file show the another character, it cannot show the original...
0
7551
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...
0
7477
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...
1
7509
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...
0
5118
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...
0
3524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1971
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1084
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
790
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.