Solved

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

Posted on 2003-10-25
5
224 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 30 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why would downloading El capitan OSX update be troublesome e.g timeout many many times?? 11 514
how to understand recursion 12 219
Least Squares Curve Fitting 4 61
max float value 3 26
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now