populating my object model from XMl file

E

enigma261

Hi,

I am a XML beginner.
I need some guidance in intrepreting a XML file
and then populating my object model.

Following is an example of the XML file ..

<Tom>
<Version>x.0</Version>
<Ref>
<Id>5555</Id>
<SubList>
<Sub>
<Type>zzzz</Type>
</Sub>
<Sub>
<Type>tttt</Type>
</Sub>
</SubList>
<VarList>
<Var>
<Type>kkkk</Type>
</Var>
<Var>
<Type>mmmm</Type>
</Var>
</VarList>
</Ref>
</Tom>

After, I parse this file, I end up with a name-value pair,
that looks like following

..Tom.Version x.0
..Tom.Ref.Id 5555
..Tom.Ref.SubList.Sub.Type zzzz
..Tom.Ref.SubList.Sub.Type tttt
..Tom.Ref.VarList.Var.Type kkkk
..Tom.Ref.VarList.Var.Type mmmm

After I have this name-value pair, I would like to populate my object
model, which looks something like following

There is a class called "Tom" that has a property called "Version".
"Tom" has a pointer to another class called "Ref" which in turn
has a property called "Id". "Ref" also holds two lists each holding
pointers to "Sub" and "Var".

This is just an example. But the general model is very similar.

I need some guidance in populating my object model after I have the
name-value pair. ( At this point, I don't think it is really an
XMl issue).
Any other better way would also be highyl appreciated.

thanks
 
M

Martin Honnen

I need some guidance in intrepreting a XML file
and then populating my object model.

Following is an example of the XML file ..

<Tom>
<Version>x.0</Version>
<Ref>
<Id>5555</Id>
<SubList>
<Sub>
<Type>zzzz</Type>
</Sub>
<Sub>
<Type>tttt</Type>
</Sub>
</SubList>
<VarList>
<Var>
<Type>kkkk</Type>
</Var>
<Var>
<Type>mmmm</Type>
</Var>
</VarList>
</Ref>
</Tom>

After, I parse this file, I end up with a name-value pair,
that looks like following

.Tom.Version x.0
.Tom.Ref.Id 5555
.Tom.Ref.SubList.Sub.Type zzzz
.Tom.Ref.SubList.Sub.Type tttt
.Tom.Ref.VarList.Var.Type kkkk
.Tom.Ref.VarList.Var.Type mmmm

After I have this name-value pair, I would like to populate my object
model, which looks something like following

There is a class called "Tom" that has a property called "Version".
"Tom" has a pointer to another class called "Ref" which in turn
has a property called "Id". "Ref" also holds two lists each holding
pointers to "Sub" and "Var".

This is just an example. But the general model is very similar.

You haven't told us which language you are using, for Java you might
want to look into XMLBeans:
<http://xmlbeans.apache.org/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top