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

read xml and create object

i have a xml file which include object name and its property.

<objectname>TextBox1</objectname>
<property>Text</property>

how can i get the property source in c# ? . I have to create an object from
string data type like TextBox1.Text . I wonder that if it is possible or not.

regards.
Nov 16 '05 #1
3 7262
Do you mean to say that you have some UI controls, and @ run time, you want
to set some properties of those controls to values from the XML file? If yes,
you could easily use Reflection to accomplish that.

"xenofex" wrote:
i have a xml file which include object name and its property.

<objectname>TextBox1</objectname>
<property>Text</property>

how can i get the property source in c# ? . I have to create an object from
string data type like TextBox1.Text . I wonder that if it is possible or not.

regards.

Nov 16 '05 #2
Hi,

You can use reflection to do this, but you will also need state the type of
the control to create, this unless ALL controls are of the same type.
You use Activator.CreateInstance() to create the object and later assign the
properties using reflection.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"xenofex" <xe*****@discussions.microsoft.com> wrote in message
news:5B**********************************@microsof t.com...
i have a xml file which include object name and its property.

<objectname>TextBox1</objectname>
<property>Text</property>

how can i get the property source in c# ? . I have to create an object from string data type like TextBox1.Text . I wonder that if it is possible or not.
regards.

Nov 16 '05 #3
can you give me example ?

"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT dot.state.fl.us> wrote in message news:<eI*************@TK2MSFTNGP12.phx.gbl>...
Hi,

You can use reflection to do this, but you will also need state the type of
the control to create, this unless ALL controls are of the same type.
You use Activator.CreateInstance() to create the object and later assign the
properties using reflection.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"xenofex" <xe*****@discussions.microsoft.com> wrote in message
news:5B**********************************@microsof t.com...
i have a xml file which include object name and its property.

<objectname>TextBox1</objectname>
<property>Text</property>

how can i get the property source in c# ? . I have to create an object

from
string data type like TextBox1.Text . I wonder that if it is possible or

not.

regards.

Nov 16 '05 #4

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

Similar topics

21
by: Jason Heyes | last post by:
I want to allow objects of my class to be read from an input stream. I am having trouble with the implementation. Here are the different approaches I have tried: // Version 1.0 - Default...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
6
by: BBM | last post by:
I have an object that has a fairly complex construction sequence, so I have written a dedicated "factory" class that invokes the constructor of my object class (which does nothing but instantiate...
1
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
12
by: James Norton-Jones | last post by:
Hi, Am I trying to hold the data of a DataGrid in a label so that when the form is reposted the DataGrid can be repopulated. The problem I am having is that I don't understand how to get the...
1
by: Paloma GarcĂ­a | last post by:
Dear all, I have created personalized configuration sections in my web project following the instructions described in this page...
6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only attributes that generate an exception if I try to...
4
by: Kuldeep | last post by:
Hi All, I am trying to read the contents of a page through its URL. My code snippet is as follows: public void mtdGetPageDataHWR() { HttpWebRequest objRequ =...
1
by: =?Utf-8?B?Y29uc3RhbnRpbg==?= | last post by:
I have problem with my code I need to read from Excel worksheet into dataset the problem is in this line oleda.Fill(ds). The data adapter should fill dataSet with data from Excel worksheet but...
2
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi Is there any way to Read an INIFile from a string or Stream instead of a physical file ??? I want to read the INIFile into a string then store in a db but when I read the string from the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.