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

want to set properties in C#

If I have an xml file and want to set some properties in it (read and write
it I guess), what is the best alternative?

I don't want to use xlst - this seems like I should be able to just specify
the node and replace the parameter similar to what I am doing now in
InstallScript:

oConfig = CreateObject("MSXML.DOMDocument");
oConfig.load(configFile);
oLanguageCtl =
oConfig.selectSingleNode("Config/GeneralDlgs/LocaleInfoDlg/LanguageCtl");
oLanguageCtl.text = Locale;
....
oConfig.save(configFile);

for the parameter shown here:

<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Doc\XML_based_si lent_install\InstallConfig
_APJSP.xsd">
<GeneralDlgs>
<LocaleInfoDlg Visible="false">
<LanguageCtl>English (United States)</LanguageCtl>

Nov 12 '05 #1
2 1160
"Owen Corpening" <oc********@acornsys.com> wrote in message news:OC*************@TK2MSFTNGP15.phx.gbl...
If I have an xml file and want to set some properties in it (read and write
it I guess), what is the best alternative?


This is the .NET solution closest to your scripting language example,

- - - configDocument.cs (excerpt)
using System;
using System.Xml;
: :
XmlDocument oConfig = new XmlDocument( );
oConfig.Load( "config.xml");
XmlNode oLanguageCtl = oConfig.SelectSingleNode(
"Config/GeneralDlgs/LocaleInfoDlg/LanguageCtl");
oLanguageCtl.FirstChild.Value = "Spanish (Spain)";
: :
Console.WriteLine( oConfig.OuterXml);
- - -
Derek Harmon
Nov 12 '05 #2
wow! Perfect! The scripting was abhorent but this looks fabulous! Thanks

"Derek Harmon" <lo*******@msn.com> wrote in message
news:Ov*************@TK2MSFTNGP12.phx.gbl...
"Owen Corpening" <oc********@acornsys.com> wrote in message

news:OC*************@TK2MSFTNGP15.phx.gbl...
If I have an xml file and want to set some properties in it (read and write it I guess), what is the best alternative?


This is the .NET solution closest to your scripting language example,

- - - configDocument.cs (excerpt)
using System;
using System.Xml;
: :
XmlDocument oConfig = new XmlDocument( );
oConfig.Load( "config.xml");
XmlNode oLanguageCtl = oConfig.SelectSingleNode(
"Config/GeneralDlgs/LocaleInfoDlg/LanguageCtl");
oLanguageCtl.FirstChild.Value = "Spanish (Spain)";
: :
Console.WriteLine( oConfig.OuterXml);
- - -
Derek Harmon

Nov 12 '05 #3

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

Similar topics

2
by: Rick Austin | last post by:
I recently had to perform a reinstalltion of Windows XP (my registry seems to have become corrupt). After this completed I had to reinstall all applications since most use the registry for settings,...
9
by: kj | last post by:
Is there any way to programmatically discover and inspect *all* the properties of an object, even those that are not enumerable through a for/in loop? Thanks! kj -- NOTE: In my address...
5
by: Flipje | last post by:
In my view, there is a major drawback to using attributes: the getter and the setter have identical protection levels. But I usually want the getter to be public and the setter to be protected or...
0
by: lester | last post by:
I am using a C++ dll and need to run unsafe code because of pointers. I'm using Visual Studio.NET 2002. Everything I've seen says to go to the project properties, then build properities page and...
3
by: Javaman59 | last post by:
Visual Studio 2003/5 question... I'm in the solution explorer, looking at a file. I want to find it's path. The only way i know of doing this is to open it (with a double-click), then mouse over...
182
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
1
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled...
1
by: tony | last post by:
Hello!! I have the method CollectData that I want to use Reflection on. I use foreach looping through a collection of DSRow. This DSRow does not have a property but I can add one if it would...
11
by: Genalube | last post by:
I am new to access, so I figure this is an easy question to answer. I just can't find it on my own. Background: Two tables with a one to many relationship (irelevantField1 is a place holder,...
0
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to...
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: 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: 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: 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
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
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...

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.