473,386 Members | 1,791 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.

Tags inside value field of appsettings in web.config

i need to write a xml data inside the value field in web.config file.
it looks likes this
<configuration>
<appSettings>
<add key="MyXmlData" value="<data><type></type>........." />
</appSettings>
</configuration>

but i get an error message

some one help me

Dec 22 '05 #1
1 1549
You need to encode/escape the characters. You can do it manually if you
know all of the rules, but I wrote a little utility for myself that I
know will do it right. I guess I should post the full app at some point,
but the relevant method is:

public string Encode(string input)
{
StringBuilder output = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(output,
CultureInfo.InvariantCulture))
{

XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.WriteStartElement("element");
xmlWriter.WriteAttributeString("attribute", input);
xmlWriter.WriteEndElement();
xmlWriter.Close();
}
return output.ToString();
}
Just create a simple WinForms app with a textbox to past a value into, a
button that runs the Encode method, and then a textbox for the output
(not label - you want to be able to select the output for copy/paste).
Joshua Flanagan
http://flimflan.com/blog
Dec 22 '05 #2

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

Similar topics

1
by: lily82 | last post by:
I am new to xml and I am trying to use xml as web.config file. I will use asp.net form to get the web.config settings. Below is my web.config file: <?xml version="1.0" encoding="UTF-8" ?> ...
4
by: John Galt | last post by:
I am trying to read the "ConnectionString" value from my app.exe.config file, but am not sure of the format to do this. It is of the form: <?xml version="1.0" encoding="utf-8"?>...
3
by: jason | last post by:
i am coding a simple console application with Visual C# .NET in Visual Studio .NET my config file (myapp.exe.config) has the following appSettings section: <appSettings> <add key="myKey"...
5
by: Marcos MOS | last post by:
Hi, I've put a appSetting tag into my web.config, but when I try to catch its value to my Image WebControl occurs the follow error: "Server tags cannot contain <% ... %> constructs." on...
2
by: Beach Bum | last post by:
Is there a way to dynamically choose what session state server inside of web.config similar in the way you can change options inside of the appSettings using the file attribute of the appSettings...
3
by: serge calderara | last post by:
Dear all, Let say that I have developped a funcionnal library that I distribute for use. That library can be integrated in a project by referencing it and then use it by calling function and...
2
by: mahesh.anjani | last post by:
hi i have stored my connction string in web.config as we do usually. code of web.confing is given below. check the password field contain "&" character. now when i run my application it gives...
3
by: prabu.girirajan | last post by:
Hi, I have a web application which internally calls certain web methods of a web service. This web service has a interop to ATL COM Component and that ATL component calls a .NET assembly. I would...
1
by: =?Utf-8?B?c3B1cnZpYQ==?= | last post by:
I have a simple C# VS 2005 console application that contains a class and an app.config file. My app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key =...
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: 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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.