Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

688 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