473,748 Members | 10,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedd XML within XML - Possible ??

Hi

I need to store some configuration settings in a db
using an 2 fileds

ID Field and String Field

The ID Field is a unique key and the string holds a xml string that store my
settings
Now I need to modify my configuration xml to store another parameter which
is a xml document itself. I could probably store a key in the xml to point
to the 2nd XML document but I was wondering is there a way to embed an
xml string within another xml string as an attribute within an element???

Thanks

Oct 15 '08 #1
3 1894
Hi sippyuconn,

From your description, I understand that you want to store some XML format
data via the AppSettings <itemin .net application's configuration file,
correct?

Based on my experience, it is not quite recommended that we store such
complex format text in the appsettings. this is because AppSettings <item>
use attribute to hold item value, which is designed to store some simple
text values.

If you do want to store complex XML data into the attribute field. I think
you can consider the following means:

1. First, your xml data have to be encoded into a safe format(which won't
violate the container xml document). One simple means is using HtmlEncode
to encode the embeded xml(which is to put into appsetting item).

2. When you read the item out, you need to HtmlDecode it.

Here are two simple functions demonstrate this:

=============== ==============
static void StoreXML()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"< root><items>
<item id ='1'></item><item id='2'></item>
</items>
</root>
");

Configuration config
=ConfigurationM anager.OpenExeC onfiguration( ConfigurationUs erLevel.None);

doc.PreserveWhi tespace = false;
StringWriter sw = new StringWriter();
doc.Save(sw);

config.AppSetti ngs.Settings["doc1"].Value = null;
config.AppSetti ngs.Settings["doc1"].Value =
HttpUtility.Htm lEncode(sw.ToSt ring());

config.Save();

}

static void ReadXML()
{
string rawdoc = ConfigurationMa nager.AppSettin gs["doc1"];

XmlDocument doc = new XmlDocument();

string xml = HttpUtility.Htm lDecode(rawdoc) ;

doc.LoadXml(xml );

Console.WriteLi ne(doc.OuterXml );

}
=============== ==========

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?c2lwcHl1Y29 ubg==?= <si********@new sgroup.nospam>
Subject: Embedd XML within XML - Possible ??
Date: Tue, 14 Oct 2008 18:46:00 -0700
>
Hi

I need to store some configuration settings in a db
using an 2 fileds

ID Field and String Field

The ID Field is a unique key and the string holds a xml string that store
my
>settings
Now I need to modify my configuration xml to store another parameter which
is a xml document itself. I could probably store a key in the xml to point
to the 2nd XML document but I was wondering is there a way to embed an
xml string within another xml string as an attribute within an element???

Thanks

Oct 15 '08 #2

If you're doing this so you can store "complex" information in your
app.config or web.config, this is a hack.

...

A better solution would be to author your own configuration section
"Handler" (and "Settings") class.

I have a working example here:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!138.entry

Ignore the SMTP stuff, just focus on the
EmailSmtpSettin gsHandler : IConfigurationS ectionHandler
class...and how I parse the xml to create a strong object.
Or go here:
http://msdn.microsoft.com/en-us/library/2tw134k3.aspx
or here
http://support.microsoft.com/default...b;en-us;309045
But "xml inside an xml" doesn't have a good feel to it, IMHO.


"sippyuconn " <si********@new sgroup.nospamwr ote in message
news:37******** *************** ***********@mic rosoft.com...
Hi

I need to store some configuration settings in a db
using an 2 fileds

ID Field and String Field

The ID Field is a unique key and the string holds a xml string that store
my
settings
Now I need to modify my configuration xml to store another parameter which
is a xml document itself. I could probably store a key in the xml to point
to the 2nd XML document but I was wondering is there a way to embed an
xml string within another xml string as an attribute within an element???

Thanks

Oct 15 '08 #3
Hi Sippy,

Have you got any progress on this issue or does the suggestion in my last
reply help you some? If there is anything else we can help, please feel
free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

--------------------
>From: =?Utf-8?B?c2lwcHl1Y29 ubg==?= <si********@new sgroup.nospam>
Subject: Embedd XML within XML - Possible ??
Date: Tue, 14 Oct 2008 18:46:00 -0700
>Hi

I need to store some configuration settings in a db
using an 2 fileds

ID Field and String Field

The ID Field is a unique key and the string holds a xml string that store
my
>settings
Now I need to modify my configuration xml to store another parameter which
is a xml document itself. I could probably store a key in the xml to point
to the 2nd XML document but I was wondering is there a way to embed an
xml string within another xml string as an attribute within an element???

Thanks

Oct 20 '08 #4

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

Similar topics

6
2226
by: mh | last post by:
Hi everybod who knows the *.dll to embedd the command prompt into C#, what i want to do, is make a graphical command prompt based on System.Windows.Forms Thanks for helping
0
1212
by: Nuno Magalhaes | last post by:
How do I embedd the MediaPlayer (msdxm.ocx) in a Windows Form using C#? I do something like the code below: Player=new WindowsMediaPlayer(); Player.URL="http://"+RemoteIPTextBox.Text+":8080/"; Player.controls.play();
1
1453
by: Nuno Magalhaes | last post by:
How do I embedd an ocx control in a windows form in C#? Does it inherit from Microsoft.Windows.Forms.Form? Thanks for any response to this newbie question, Nuno Magalhaes.
1
1312
by: Anamika | last post by:
I am trying to embedd Ms Word object in asp.net application and retrieve from & save back to database. Anybody done this before ? I would appreciate if anybody send some sample code. TIA.
1
1131
by: Mike TI | last post by:
April 18, 2006 Hi all I have built a small application in VB Net 2005 that uses SQL Express 2005. Now I want to create a 'Setup Procedure' that should install the application as well as SQL Express into the client's machine. How do I embedd SQL Express installation into the application setup procedure.
3
2853
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and additionally pictures of the product are stored in an images subfolder and the database holds the file name of the relevant picture. The user can then click a button to display the picture in a pop-up window and also another button to email the potential...
1
1377
by: Joe | last post by:
Hi I am trying to build a XML db and within this I want to store an XML string as 1 element as "Info" below If I build up a XMLDocument with data - how can I transform it to a string containing &lt &gt so I can put it into my main XML document
0
1262
by: Preeti | last post by:
Hi All I am new to WPF. I need to embedd a flash video on a WPF screen. But I think mediaelement does not support that. Can anyone tell me what do I need to be able to embedd a flv video on a WPF window. Thanks in Advance Preeti http://techavenues.blogspot.com
6
3438
by: ankitkhare | last post by:
Hi, I have this javascript which i am trying to embedd in my C# code,i am not sure whether it is even possible or not! If it is possible then how can i do it?Any document or links will be helpful, Thanks, Ankit Khare
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.