Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I put the values from an xml file ,no keyboard reading is required

Posted on 2003-10-25
5
Medium Priority
?
241 Views
Last Modified: 2010-04-01
I have a programm which reads data from an xml file,I would like to put this data in to another class & would like to creat instances of the classes to access the values which is obtained by xml file.
The program which reads data from xml file is as follows:


CMarkup xml;
{
 xml.load(out.xml)//out.xml is an xml file from which data is reading
xml.Reset Pos();
xml.FindElem("root")
xml.IntoElem();

xml.FindchildElem("field1);
xml.IntoElem();

xml.FindchildElem("Data");
xml.IntoElem();
xml.FindchildElem("name")
csstring csname=xml.GetchildData();//here geting the the name from xml file
cout<<csname<<endl;//for displaying on consol

xml.FindchildElem("type")
csstring cstype=xml.GetchildData();//here geting the the type from xml file
cout<<cstype<<endl;//for displaying on consol



xml.FindchildElem("sizebytes")
csstring sizebytes=xml.GetchildData();//here geting the the sizebyte from xml file
cout<<cssizebyte<<endl;//for displaying on consol



OutofElem();
OutofElem();

}

Now I would like to create a class structure which contain the variables like name ,type,length,& would like to put whole the data which I am getting from the above programm without reading from keyboard(means I don't want to display the data on the console in the first programm but want directly putting  the data into this class variables then would like to creat instances of this class for further access.






0
Comment
Question by:syed110
  • 2
5 Comments
 

Author Comment

by:syed110
ID: 9623088
there is no answer till now,seems nobody is interested to reply me.Plz.if someone can give attention towards thi´s question.
thanx
syed110
0
 
LVL 1

Accepted Solution

by:
kellycoinguy earned 90 total points
ID: 9624835

The first thing you need to do is create a factory method that constructs new objects based upon the name of the types you encounter in your XML file. Fortunately, due to the runtime binding features of C# this is fairly easy to do.

Examine the
using System.Reflection;
namespace and you will find the functions you need to create a name from type. I haven't done it yet, but I remember reading the APIs and this did seem rather straightforward.

Populating public fields and properties dynamically is also fairly easy to do with the System.Reflection namespace.

If you need a great deal of Dynamic classes in your program, you can go REALLY crazy with the System.Reflection.Emit classes, but you're in way over your head if you start there... It allows you to dynamically create new classes on the fly.

I hope this begins to answer your questions, or at least send you off in the right direction.

-Kelly
0
 

Author Comment

by:syed110
ID: 9626353
thanx kelly,let me try....
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10546142
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: kellycoinguy {http:#9624835}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question