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

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 3231


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/cpconXMLSchemaDefinitionToolXsdexe.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:001401c64397$a4b64850$0c01a8c0@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.public.dotnet.languages.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:001401c64397$a4b64850$0c01a8c0@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:003601c643a9$0e595f70$0c01a8c0@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.public.dotnet.languages.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:001401c64397$a4b64850$0c01a8c0@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.public.dotnet.languages.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:003601c643a9$0e595f70$0c01a8c0@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.public.dotnet.languages.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:001401c64397$a4b64850$0c01a8c0@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.asp

Thanks to all who’ve respond.

_____

From: PH [mailto:no****@nospam.com]
Posted At: Thursday, March 09, 2006 4:28 PM
Posted To: microsoft.public.dotnet.languages.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.public.dotnet.languages.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:003601c643a9$0e595f70$0c01a8c0@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.public.dotnet.languages.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:001401c64397$a4b64850$0c01a8c0@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
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...
8
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,...
2
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...
4
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: ...
16
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...
2
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...
2
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
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...
10
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: ...
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: 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: 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
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.