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

write an xml with out using IO operation

hi
i want to write an xml with out using IO operation.
i dont want to write the xml in text file and then read from it.

for this i have used memory stream, but when i read the data from memory stream i gives wrong xml. some tags are added itsself in xml

here is the code.

MemoryStream str = new MemoryStream()
XmlTextWriter txtwriter = new XmlTextWriter(str,System.Text.Encoding.UTF8);
txtwriter.WriteStartDocument();
txtwriter.WriteStartElement("AssessmentOrderAcknow ledgement");
txtwriter.WriteStartElement("ReceiptId");
txtwriter.WriteAttributeString("idOwner", "The ID of the partner");
txtwriter.WriteStartElement("IdValue");
txtwriter.WriteAttributeString("name", "receiptID");
txtwriter.WriteString("[ASR unique identifier]");
txtwriter.WriteEndElement();
txtwriter.WriteEndElement();
txtwriter.WriteStartElement("AccessPoint");
txtwriter.WriteElementString("InternetWebAddress", data[0]);
txtwriter.WriteEndElement();
txtwriter.WriteStartElement("AssessmentStatus");
txtwriter.WriteElementString("Status", "[Acknowledged]");
txtwriter.WriteElementString("Details", "[Details of the status]");
txtwriter.WriteEndElement();
txtwriter.WriteEndElement();
txtwriter.Flush();
txtwriter.Close();

//Reading the xml
string xmfragment = System.Text.Encoding.UTF8.GetString(str.GetBuffer( ));

i am geting one more tag ie <string> extra and <?xml version="1.0" encoding="UTF-8" ?> extra

is there problem in coding?

or how cani achive my objective?
Jan 16 '08 #1
2 975
IanWright
179 100+
I believe its good practise to post the language that you are using in your posts.

I'm assuming C#. Have you tried looking at the XMLDataDocument class? It allows you to read/write nodes within an XML file quite nicely, and you can read it back easily with a little bit of recursion.
Jan 17 '08 #2
i am sorry that i forgot to write the language. i will keep in mind in future.
i follow your suggestion and it works. Thanks a lot for your valuable suggestion.
i have one more question that Is using string as xml format is good option for dealing with xml . or there i should use some other option???
Jan 28 '08 #3

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

Similar topics

8
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row....
0
by: Garrett Kajmowicz | last post by:
I have two implementations of stringstream and they both handle interleaved reads and writes differently. I was hoping that you might be able to shed some light as to the "correct" operation, and...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
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( )); }
5
by: Sumana | last post by:
Hi All, We developed our project on VC++.Net console application to create image of disk and to write the image We are having problem with reading and writing the sector beyond 6GB Disk or...
74
by: lovecreatesbeauty | last post by:
My small function works, but I have some questions. And I want to listen to you on How it is implemented? 1. The function does not check if parameter x is larger or smaller than parameter y. ...
12
by: Sean Davis | last post by:
I am working on a simple script to read from one database (oracle) and write to another (postgresql). I retrieve the data from oracle in chunks and drop the data to postgresql continuously. The...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.