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

XML to a file problem

mickey0
142 100+
Hello,
I'm tryoing to write a xml tree into a file and I'm near to it but my dom cantain in a text the string "www.xxxxx/fdfdfdf& dsdsfsfs.
Problem is that when I put it into DOM "&" is changed to "&" and in the file on the disk I find "&". The only way to keep it out is this below, but it's ugly. Another way please?

Expand|Select|Wrap|Line Numbers
  1.             StringWriter sw = new StringWriter();            
  2.             XmlTextWriter xw = new XmlTextWriter(sw);
  3.             xw.Formatting = Formatting.Indented;
  4.             StreamWriter writer = new StreamWriter(inputFileInfo.FullName);
  5.             pdom.Xml_doc.WriteContentTo(xw);
  6.             writer.WriteLine(sw.ToString().Replace("amp;", ""));
  7.  
Thanks in advance
Jan 27 '08 #1
1 1055
nateraaaa
663 Expert 512MB
Hello,
I'm tryoing to write a xml tree into a file and I'm near to it but my dom cantain in a text the string "www.xxxxx/fdfdfdf& dsdsfsfs.
Problem is that when I put it into DOM "&" is changed to "&" and in the file on the disk I find "&". The only way to keep it out is this below, but it's ugly. Another way please?

Expand|Select|Wrap|Line Numbers
  1.             StringWriter sw = new StringWriter();            
  2.             XmlTextWriter xw = new XmlTextWriter(sw);
  3.             xw.Formatting = Formatting.Indented;
  4.             StreamWriter writer = new StreamWriter(inputFileInfo.FullName);
  5.             pdom.Xml_doc.WriteContentTo(xw);
  6.             writer.WriteLine(sw.ToString().Replace("amp;", ""));
  7.  
Thanks in advance
You added a single line of code to fix your problem. In my mind that is not an ugly fix but you could also try making the string a literal using the @ operator. However I think this would also include your bold tags.
string a = @"www.xxxxx/fdfdfdf& dsdsfsfs";

Nathan
Jan 29 '08 #2

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

Similar topics

17
by: Sean Ross | last post by:
Hi. Recently I made a small script to do some file transferring (among other things). I wanted to monitor the progress of the file transfer, so I needed to know the size of the files I was...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
7
by: Keith Dewell | last post by:
Greetings! My current job has brought me back to working in C++ which I haven't used since school days. The solution to my problem may be trivial but I have struggled with it for the last two...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
4
by: SS | last post by:
We built an MSI file to deploy a .net app to the workstation. We created an HTML page that has a link to the MSI file. On a very sporadic basis, when the MSI is run we get the following message:...
5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
4
by: pradqdo | last post by:
Hi folks, I have a very strange problem when I try to port my client/server program to cygwin. It is a simple shell program where the server executes client's commands + it can send and receive...
4
by: Salad | last post by:
I have a situation where some, not all, users get the message "Couldn't find file "F:\AccessApps\AppName.mdw". This file is required for startup". My app the users are attempting to access is...
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: 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:
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
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
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.