473,396 Members | 2,010 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,396 software developers and data experts.

Xml writing quotes etc

Hi

Is there some kind of method to convert strings containing " < etc to
some form that it is allowed inside XML tags ?

Johan


Mar 7 '08 #1
1 1221
Sagaert Johan wrote:
Is there some kind of method to convert strings containing " < etc to
some form that it is allowed inside XML tags ?
Use XmlWriter to create your XML, it does the necessary escaping for
you. If you only want to create a text then use XmlWriterSettings with
ConformanceLevel.Fragment e.g.

XmlWriterSettings settings = new XmlWriterSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
StringWriter writer = new StringWriter();
using (XmlWriter xmlWriter = XmlWriter.Create(writer, settings))
{
xmlWriter.WriteString("a < b && b < a");
}
Console.WriteLine(writer.ToString());

writes "a &lt; b &amp;&amp; b &lt; a".

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 7 '08 #2

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

Similar topics

4
by: Andrew Crowe | last post by:
Hi guys, I'm having trouble executing commands using exec() or system() that need to write files. I've set the permissions on CMD.EXE but I can't use exec() to write any files, even if the...
8
by: Deepa | last post by:
I am writing a console app in c# wherein am converting a dataset into a CSV file. It works fine. But I have some values in the dataset which have a comma within(eg. A,B,C). When I view the CSV file...
3
by: Ian Davies | last post by:
I have the following code which displays some some formatted text in my browser. The problem is I need to create a text file and write the records from this array into it. Does anyone know how to...
4
by: (PeteCresswell) | last post by:
Is his just a flat-out "No-No" or is there some workaround when it comes time for SQL searches and DAO.FindFirsts against fields containing same? I can see maybe wrapping the value searched for...
3
by: Netfreaky | last post by:
When you type a quote in a name for example, the database is returning an error... Now i only check the name field and replace every quote to \' Is there a simple thing to replace all special...
1
by: Billy | last post by:
Hi All, I'm attempting to use the MapNetworkDrive <snippedbelow from entire code below with very poor performance results. Basically, I have very small 73kb text files that are rewritten daily...
1
by: Richard Bailey | last post by:
Howdy. I've got a simple problem that has been driving me bananas. Most of our website is still written in ASP.NET 1.1. While working on some web apps visual studio will take some tags like : ...
8
by: Can2002 | last post by:
I've been trying to put together an application to change channel on a media streaming server. The server is able to issue IR commands to its attached equipment using LIRC, with commands being...
1
by: Mudcat | last post by:
In short what I'm trying to do is read a document using an xml parser and then upload that data back into a database. I've got the code more or less completed using xml.etree.ElementTree for the...
1
by: donpur | last post by:
In Visual Basic I am attempting to write a formula that includes an explanation point out to an Excel cell. When I do, Excel puts extra single quotes into the formula. For example the following:...
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: 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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.