473,804 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reads XML node from App.Config and populates a Class

PH
Hi guys;

I got the following problem to solve, hope you can help me.

I got a XML node in App.Conf;

<CUSTOMERS>

<CUSTOMER>

<NAME =”Frank” />

<LASTNAME =”Smith”/>

<AGE= 34 />

</CUSTOMER>

<CUSTOMER>

<NAME =”Lisa” />

<LASTNAME =”Tucker”/>

<AGE= 42 />

</CUSTOMER>

<CUSTOMERS/>

I will like to populate a class called Customers that has the same
structure than the XML node Customers, with all the Customer nodes.

Is there any automated way to do this in the framework?

Thanks very much


Mar 9 '06 #1
6 3249


PH wrote:

I got a XML node in App.Conf; <CUSTOMERS>

<CUSTOMER>

<NAME =”Frank” />
That is not well-formed XML at all, you can either have
<CUSTOMER NAME="Frank" />
or
<CUSTOMER>
<NAME>Frank</NAME>
I will like to populate a class called Customers that has the same
structure than the XML node Customers, with all the Customer nodes.

Is there any automated way to do this in the framework?


You can use the xsd.exe tool to infer a schema and generate a class, see
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/cptools/html/cpconXMLSchemaD efinitionToolXs dexe.asp>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 9 '06 #2
Hi,
Why you use app.config?
This file should content only the needed configuration for your app, no data.

You can keep your data in a XML file that can be readed direcly in a dataset.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"PH" <no****@nospam. com> wrote in message news:001401c643 97$a4b64850$0c0 1a8c0@m1...
Hi guys;



I got the following problem to solve, hope you can help me.



I got a XML node in App.Conf;





<CUSTOMERS>

<CUSTOMER>

<NAME ="Frank" />

<LASTNAME ="Smith"/>

<AGE= 34 />

</CUSTOMER>



<CUSTOMER>

<NAME ="Lisa" />

<LASTNAME ="Tucker"/>

<AGE= 42 />

</CUSTOMER>

<CUSTOMERS/>



I will like to populate a class called Customers that has the same structure than the XML node Customers, with all the Customer nodes.

Is there any automated way to do this in the framework?



Thanks very much



Mar 9 '06 #3
PH


You’re right.

It will be a XML file.

Now, I want to populate a Class instead of a Dataset.

Thanks

_____

From: Ignacio Machin ( .NET/ C# MVP ) [mailto:ignacio. machin AT
dot.state.fl.us]
Posted At: Thursday, March 09, 2006 1:17 PM
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: Reads XML node from App.Config and populates a Class
Subject: Re: Reads XML node from App.Config and populates a Class
Hi,

Why you use app.config?

This file should content only the needed configuration for your app, no
data.

You can keep your data in a XML file that can be readed direcly in a
dataset.


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

"PH" <no****@nospam. com> wrote in message
news:001401c643 97$a4b64850$0c0 1a8c0@m1...

Hi guys;

I got the following problem to solve, hope you can help me.

I got a XML node in App.Conf;

<CUSTOMERS>

<CUSTOMER>

<NAME =”Frank” />

<LASTNAME =”Smith”/>

<AGE= 34 />

</CUSTOMER>

<CUSTOMER>

<NAME =”Lisa” />

<LASTNAME =”Tucker”/>

<AGE= 42 />

</CUSTOMER>

<CUSTOMERS/>

I will like to populate a class called Customers that has the same
structure than the XML node Customers, with all the Customer nodes.

Is there any automated way to do this in the framework?

Thanks very much


Mar 9 '06 #4
Hi,

What about a typed dataset?

If not you would have to create the method to populate the collection of Customers , there is nothing in the framework to do that for you.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"PH" <no****@nospam. com> wrote in message news:003601c643 a9$0e595f70$0c0 1a8c0@m1...


You're right.

It will be a XML file.



Now, I want to populate a Class instead of a Dataset.



Thanks


------------------------------------------------------------------------------

From: Ignacio Machin ( .NET/ C# MVP ) [mailto:ignacio. machin AT dot.state.fl.us]
Posted At: Thursday, March 09, 2006 1:17 PM
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: Reads XML node from App.Config and populates a Class
Subject: Re: Reads XML node from App.Config and populates a Class


Hi,





Why you use app.config?

This file should content only the needed configuration for your app, no data.



You can keep your data in a XML file that can be readed direcly in a dataset.




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





"PH" <no****@nospam. com> wrote in message news:001401c643 97$a4b64850$0c0 1a8c0@m1...

Hi guys;



I got the following problem to solve, hope you can help me.



I got a XML node in App.Conf;





<CUSTOMERS>

<CUSTOMER>

<NAME ="Frank" />

<LASTNAME ="Smith"/>

<AGE= 34 />

</CUSTOMER>



<CUSTOMER>

<NAME ="Lisa" />

<LASTNAME ="Tucker"/>

<AGE= 42 />

</CUSTOMER>

<CUSTOMERS/>



I will like to populate a class called Customers that has the same structure than the XML node Customers, with all the Customer nodes.

Is there any automated way to do this in the framework?



Thanks very much



Mar 9 '06 #5
PH
Ok I might use that.

Thanks Igancio.

_____

From: Ignacio Machin ( .NET/ C# MVP ) [mailto:ignacio. machin AT
dot.state.fl.us]
Posted At: Thursday, March 09, 2006 4:05 PM
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: Reads XML node from App.Config and populates a Class
Subject: Re: Reads XML node from App.Config and populates a Class
Hi,

What about a typed dataset?

If not you would have to create the method to populate the collection of
Customers , there is nothing in the framework to do that for you.


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

"PH" <no****@nospam. com> wrote in message
news:003601c643 a9$0e595f70$0c0 1a8c0@m1...

You’re right.

It will be a XML file.

Now, I want to populate a Class instead of a Dataset.

Thanks


_____
From: Ignacio Machin ( .NET/ C# MVP ) [mailto:ignacio. machin AT
dot.state.fl.us]
Posted At: Thursday, March 09, 2006 1:17 PM
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: Reads XML node from App.Config and populates a Class
Subject: Re: Reads XML node from App.Config and populates a Class
Hi,

Why you use app.config?

This file should content only the needed configuration for your app, no
data.

You can keep your data in a XML file that can be readed direcly in a
dataset.


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

"PH" <no****@nospam. com> wrote in message
news:001401c643 97$a4b64850$0c0 1a8c0@m1...

Hi guys;

I got the following problem to solve, hope you can help me.

I got a XML node in App.Conf;

<CUSTOMERS>

<CUSTOMER>

<NAME =”Frank” />

<LASTNAME =”Smith”/>

<AGE= 34 />

</CUSTOMER>

<CUSTOMER>

<NAME =”Lisa” />

<LASTNAME =”Tucker”/>

<AGE= 42 />

</CUSTOMER>

<CUSTOMERS/>

I will like to populate a class called Customers that has the same
structure than the XML node Customers, with all the Customer nodes.

Is there any automated way to do this in the framework?

Thanks very much


Mar 9 '06 #6
PH
XML Serialization is what I’m looking for.

http://msdn.microsoft.com/library/?u...ide/html/cpcon
serialization.a sp

Thanks to all who’ve respond.

_____

From: PH [mailto:no****@n ospam.com]
Posted At: Thursday, March 09, 2006 4:28 PM
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: Reads XML node from App.Config and populates a Class
Subject: Re: Reads XML node from App.Config and populates a Class
Ok I might use that.

Thanks Igancio.

_____

From: Ignacio Machin ( .NET/ C# MVP ) [mailto:ignacio. machin AT
dot.state.fl.us]
Posted At: Thursday, March 09, 2006 4:05 PM
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: Reads XML node from App.Config and populates a Class
Subject: Re: Reads XML node from App.Config and populates a Class
Hi,

What about a typed dataset?

If not you would have to create the method to populate the collection of
Customers , there is nothing in the framework to do that for you.


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

"PH" <no****@nospam. com> wrote in message
news:003601c643 a9$0e595f70$0c0 1a8c0@m1...

You’re right.

It will be a XML file.

Now, I want to populate a Class instead of a Dataset.

Thanks


_____
From: Ignacio Machin ( .NET/ C# MVP ) [mailto:ignacio. machin AT
dot.state.fl.us]
Posted At: Thursday, March 09, 2006 1:17 PM
Posted To: microsoft.publi c.dotnet.langua ges.csharp
Conversation: Reads XML node from App.Config and populates a Class
Subject: Re: Reads XML node from App.Config and populates a Class
Hi,

Why you use app.config?

This file should content only the needed configuration for your app, no
data.

You can keep your data in a XML file that can be readed direcly in a
dataset.


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

"PH" <no****@nospam. com> wrote in message
news:001401c643 97$a4b64850$0c0 1a8c0@m1...

Hi guys;

I got the following problem to solve, hope you can help me.

I got a XML node in App.Conf;

<CUSTOMERS>

<CUSTOMER>

<NAME =”Frank” />

<LASTNAME =”Smith”/>

<AGE= 34 />

</CUSTOMER>

<CUSTOMER>

<NAME =”Lisa” />

<LASTNAME =”Tucker”/>

<AGE= 42 />

</CUSTOMER>

<CUSTOMERS/>

I will like to populate a class called Customers that has the same
structure than the XML node Customers, with all the Customer nodes.

Is there any automated way to do this in the framework?

Thanks very much


Mar 9 '06 #7

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

Similar topics

8
3078
by: J Peterman | last post by:
Im having a nightmare trying to understand these nodes and linked lists. I've posted my code for my node.h, node.cpp, linkedlist.h and linkedlist.cpp files in separates replies. Can someone explain to me how I create a list and traverse it? In particular, how do I make use of the node.h method GetNext()? I don;t know what to do with it.
8
2220
by: Ryan Stewart | last post by:
Putting the following code in a page seems to make it go into an infinite loop unless you give it a very simple node to work with. Either that or it's very very slow. I'm somewhat new to this, having limited experience with hacking out JavaScript but no serious coding with it. I do have programming experience though. The logic seems fine to me. Is there something I'm missing? <script type="text/javascript"> var out = "";
2
7691
by: Keith M | last post by:
Hi, I have found a very useful piece of code in the msdn which shows how to load an xml config file, search for a particular value and replace it. Could someone possibly convert it to C# from the VB I have? I also would like to use similar code to update the machine.config file so if someone could explain how to add a node ("appSettings") if node not found and also how to add a key value pair into the "appSettings" node if found I would...
4
1800
by: Grant | last post by:
Gday, I am using the sample code at: http://support.microsoft.com/default.aspx?scid=kb;en-us;317666 to modify an existing XML document. The XML document looks like the following: --------------------------- <parameters> <Config-File> <Value>c:\config.xml</Value>
16
1997
by: Timm | last post by:
I'm trying to use ASP objects (basically formed and populated based on Web.Config settings) and I want to use them in a different non-asp program with minimal reprogramming. So, my question is how do I mock up what ASP does to read the Web.Config file? I've tried messing around in the System.Configuration library and haven't been able to find anything from taking a quick look at the objects and their methods (for the goal of populating the...
2
7503
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView nodes. The TreeView populates dynamically as there are a significant number of nodes. The DataGrid displays both the items and the nodes from the TreeView. Using the explorer analogy this means the TreeView shows folders, and the DataGrid folders...
2
1095
by: PH | last post by:
Hi guys; I got the following problem to solve, hope you can help me. I got a XML node in App.Conf; <CUSTOMERS> <CUSTOMER> <NAME =”Frank” />
1
2899
by: John Wilhelm | last post by:
I'm having a problem in by VB.net 2005 application. When i try to get a node from my app.config file the node come back with "nothing". The xmldocment loads OK, but I can't retrive a node. The app.config file is listed below and the code is listed below that, the line with "-->>" is where i try to get the node. Can anyone see where I'm going wrong. A dump of the xmlDocument is listed below the code. Note: "MyKey" is set to "Reports"
10
8819
by: Simon Brooke | last post by:
The DOM API has included public Node importNode(Node,boolean) as a method of the Document interface for a long time. Does anything actually implement it? Xerces 2 is giving me: org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation. at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown Source) at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown Source)
0
9714
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
9594
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
10599
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
10347
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
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.