Question on XMLSerialization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe Cool

    #1

    Question on XMLSerialization

    I have an XML file that is created by an application that I do not
    have the source to and have no control over at all. I would like to
    read this XML file using VS2005 VB with XMLSerializatio n. The
    following XML file exhibits the structure of this file:

    <Root>
    <Group>
    <TypeA Attrib1="xxx" Attrib2="xxx">
    <TypeAProperty1 >xxx</TypeAProperty1>
    <TypeAProperty2 >zzz</TypeAProperty2>
    </TypeA>
    <TypeB Attrib1="xxx">
    <TypeBProperty1 >xxx</TypeBProperty1>
    </TypeB>
    </Group>
    </Root>

    The problem is how to define a class that will be the target of the
    Group node list. There can be a variable number of types. Different
    types will have each own list of attributes and nodelist. The list of
    types in the group can be any mix of different types in any order, but
    the order matters.

    I cannot figure out how to structure such a class. Any help will be
    appreciated.


  • Cor Ligthert [MVP]

    #2
    Re: Question on XMLSerializatio n

    Joe,

    Any reason that you want to use serialization because an XML file is a kind
    of serialized file.

    If this is the result of a XMLserialized object, than you never get it back
    to that not knowed Type, you only have the property dataparts.

    Why not just read it?

    Cor

    "Joe Cool" <joecool@home.n et> schreef in bericht
    news:9h39a254sl ilhuo6c5si1522b v7endkoh5@4ax.c om...[color=blue]
    >I have an XML file that is created by an application that I do not
    > have the source to and have no control over at all. I would like to
    > read this XML file using VS2005 VB with XMLSerializatio n. The
    > following XML file exhibits the structure of this file:
    >
    > <Root>
    > <Group>
    > <TypeA Attrib1="xxx" Attrib2="xxx">
    > <TypeAProperty1 >xxx</TypeAProperty1>
    > <TypeAProperty2 >zzz</TypeAProperty2>
    > </TypeA>
    > <TypeB Attrib1="xxx">
    > <TypeBProperty1 >xxx</TypeBProperty1>
    > </TypeB>
    > </Group>
    > </Root>
    >
    > The problem is how to define a class that will be the target of the
    > Group node list. There can be a variable number of types. Different
    > types will have each own list of attributes and nodelist. The list of
    > types in the group can be any mix of different types in any order, but
    > the order matters.
    >
    > I cannot figure out how to structure such a class. Any help will be
    > appreciated.
    >
    >[/color]


    Comment

    • Joe Cool

      #3
      Re: Question on XMLSerializatio n

      On Fri, 30 Jun 2006 07:07:31 +0200, "Cor Ligthert [MVP]"
      <notmyfirstname @planet.nl> wrote:
      [color=blue]
      >Joe,
      >
      >Any reason that you want to use serialization because an XML file is a kind
      >of serialized file.[/color]

      I do not have access to the code that generated the XML file, so I
      have no idea if it is a product of serialization or not.
      [color=blue]
      >
      >If this is the result of a XMLserialized object, than you never get it back
      >to that not knowed Type, you only have the property dataparts.
      >
      >Why not just read it?[/color]

      Since I have figured out how to use XMLSerialzation , I prefer to use
      it when I can to read and write XML. But I'm afraid I am going to have
      to go back to the DOM to read this one in.
      [color=blue]
      >
      >Cor
      >
      >"Joe Cool" <joecool@home.n et> schreef in bericht
      >news:9h39a254s lilhuo6c5si1522 bv7endkoh5@4ax. com...[color=green]
      >>I have an XML file that is created by an application that I do not
      >> have the source to and have no control over at all. I would like to
      >> read this XML file using VS2005 VB with XMLSerializatio n. The
      >> following XML file exhibits the structure of this file:
      >>
      >> <Root>
      >> <Group>
      >> <TypeA Attrib1="xxx" Attrib2="xxx">
      >> <TypeAProperty1 >xxx</TypeAProperty1>
      >> <TypeAProperty2 >zzz</TypeAProperty2>
      >> </TypeA>
      >> <TypeB Attrib1="xxx">
      >> <TypeBProperty1 >xxx</TypeBProperty1>
      >> </TypeB>
      >> </Group>
      >> </Root>
      >>
      >> The problem is how to define a class that will be the target of the
      >> Group node list. There can be a variable number of types. Different
      >> types will have each own list of attributes and nodelist. The list of
      >> types in the group can be any mix of different types in any order, but
      >> the order matters.
      >>
      >> I cannot figure out how to structure such a class. Any help will be
      >> appreciated.
      >>
      >>[/color]
      >[/color]

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Question on XMLSerializatio n

        Joe,

        Probably can you use the xmlnode reader.



        I hope this helps,

        Cor

        "Joe Cool" <joecool@home.n et> schreef in bericht
        news:bk4ba2d4aq dt4u1fp7ruu7jvo a48t452hg@4ax.c om...[color=blue]
        > On Fri, 30 Jun 2006 07:07:31 +0200, "Cor Ligthert [MVP]"
        > <notmyfirstname @planet.nl> wrote:
        >[color=green]
        >>Joe,
        >>
        >>Any reason that you want to use serialization because an XML file is a
        >>kind
        >>of serialized file.[/color]
        >
        > I do not have access to the code that generated the XML file, so I
        > have no idea if it is a product of serialization or not.
        >[color=green]
        >>
        >>If this is the result of a XMLserialized object, than you never get it
        >>back
        >>to that not knowed Type, you only have the property dataparts.
        >>
        >>Why not just read it?[/color]
        >
        > Since I have figured out how to use XMLSerialzation , I prefer to use
        > it when I can to read and write XML. But I'm afraid I am going to have
        > to go back to the DOM to read this one in.
        >[color=green]
        >>
        >>Cor
        >>
        >>"Joe Cool" <joecool@home.n et> schreef in bericht
        >>news:9h39a254 slilhuo6c5si152 2bv7endkoh5@4ax .com...[color=darkred]
        >>>I have an XML file that is created by an application that I do not
        >>> have the source to and have no control over at all. I would like to
        >>> read this XML file using VS2005 VB with XMLSerializatio n. The
        >>> following XML file exhibits the structure of this file:
        >>>
        >>> <Root>
        >>> <Group>
        >>> <TypeA Attrib1="xxx" Attrib2="xxx">
        >>> <TypeAProperty1 >xxx</TypeAProperty1>
        >>> <TypeAProperty2 >zzz</TypeAProperty2>
        >>> </TypeA>
        >>> <TypeB Attrib1="xxx">
        >>> <TypeBProperty1 >xxx</TypeBProperty1>
        >>> </TypeB>
        >>> </Group>
        >>> </Root>
        >>>
        >>> The problem is how to define a class that will be the target of the
        >>> Group node list. There can be a variable number of types. Different
        >>> types will have each own list of attributes and nodelist. The list of
        >>> types in the group can be any mix of different types in any order, but
        >>> the order matters.
        >>>
        >>> I cannot figure out how to structure such a class. Any help will be
        >>> appreciated.
        >>>
        >>>[/color]
        >>[/color][/color]


        Comment

        Working...