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

read file xmlreader and writer xmlwriter after root node

Hello,
first i am creating xml file if file does not exist.
Expand|Select|Wrap|Line Numbers
  1. String myFile = "C:\myxmlfile.xml"; 
  2. if (!File.Exists(myFile)) { 
  3. using (FileStream conStream = new FileStream(myFile, FileMode.Create, FileAccess.Write)) { 
  4. XmlWriter conWriter = new XmlTextWriter(conStream, Encoding.UTF8); 
  5. conWriter.WriteStartDocument(); 
  6. conWriter.WriteStartElement("myrootnode"); 
  7. conWriter.WriteStartElement("myfirstnode"); 
  8. conWriter.WriteEndDocument(); 
  9. conWriter.Close(); 
  10. conStream.Close(); 
  11. else 
  12. here read file which i just created in above code and write after new entries after root node, How to implement it or How to search for rootnode and attach new entries after root node? 
  13. Any help would be highly appreciated. 
  14. Thanks 
Best Regards
Adnan
Oct 9 '09 #1
2 4685
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Oct 9 '09 #2
GaryTexmo
1,501 Expert 1GB
For working with XML files, I'd highly recommend the XmlDocument class, and accompanying XmlNode classes.

http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
http://msdn.microsoft.com/en-us/libr...l.xmlnode.aspx

The thing to know is that XML in an XmlDocument object is set up as a hierarchical node structure... think a TreeView object. So once you read your XML text into the XmlDocument object, you can traverse through the ChildNodes recursively.

Play around with it and see what you can find out :)
Oct 9 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Garyrek | last post by:
Hi I have an url where I have xml data POSTED and I need to parse the URL to read the data - Meanwhile here is my xml data =================================== <?xml version="1.0"...
7
by: Leszek | last post by:
Hello, I have an XmlReader object containg some Xml code. I would like to export this document from the reader to an Xml file. How to do this? Thanks for any hints, Leszek Taratuta
3
by: Michael Malinak | last post by:
Since XmlWriter offers so many nice options for formatting, I thought it would be nice to read in via XmlReader, and write back out via XmlWriter. It might be overkill, but I'd also like to be able...
1
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....
0
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
10
by: JJ | last post by:
How can I get a SiteMapNodeCollection to output as an XML file?
3
by: J055 | last post by:
Hi I'd like to get a populated datatable, create an in memory xml document (file shouldn't be more than a couple of meg), load an XSLT file, do a transform and stream it to a browser. What am I...
0
by: jakerad1979 | last post by:
I am writing an application in VB.net, visual studio 2005 and I want to create a XML file to pass off to a HTTPRequest in javascript. I have tried to pass it an xmldocument with out saving it, but...
0
by: BobbyS | last post by:
I've a xml file.I'm taking its data passing it to a method in string form and converting that string "xmlData" to a array of bytes by Convert.FromBase64String(xmlData) but I'm getting a exception...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
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
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.