populating my object model from XMl file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • enigma261@yahoo.com

    populating my object model from XMl file

    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.SubLi st.Sub.Type zzzz
    ..Tom.Ref.SubLi st.Sub.Type tttt
    ..Tom.Ref.VarLi st.Var.Type kkkk
    ..Tom.Ref.VarLi st.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

  • Martin Honnen

    #2
    Re: populating my object model from XMl file



    enigma261@yahoo .com wrote:

    [color=blue]
    > 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.SubLis t.Sub.Type zzzz
    > .Tom.Ref.SubLis t.Sub.Type tttt
    > .Tom.Ref.VarLis t.Var.Type kkkk
    > .Tom.Ref.VarLis t.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.[/color]

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

    --

    Martin Honnen

    Comment

    • enigma261@yahoo.com

      #3
      Re: populating my object model from XMl file

      I am using C++
      thanks

      Comment

      Working...