Question about XMLDataDocument

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mathew Relick

    Question about XMLDataDocument

    I'm relatively new to this sort of thing, so forgive me if this is
    completely off base, but I'm having a problem getting the
    XMLDataDocument to do what I need it to.

    I have a small test application that has a DataSet with two data
    tables, Person and Home. I've setup Home as a child of Person. What
    I want to do is to load data into these two tables, and then have the
    data document create the xml with the child nodes (home) nested under
    the parent node (person). Is this possible??? The code snippet I
    have to load and output the xml is as follows:

    DsTester ds = new DsTester();
    DsTester.Person DataTable pdt =
    (DsTester.Perso nDataTable)ds.T ables["Person"];
    DsTester.HomeDa taTable hdt =
    (DsTester.HomeD ataTable)ds.Tab les["Home"];
    pdt.AddPersonRo w(12,"John");
    hdt.AddHomeRow( 1,pdt[0], "MyHome");
    XmlDataDocument xdoc = new XmlDataDocument (ds);
    System.Diagnost ics.Debug.Write Line(xdoc.Outer Xml);


    What it outputs is:
    <DsTester xmlns="http://tempuri.org/Dataset1.xsd">
    <Person>
    <PersonID>12</PersonID>
    <Name>John</Name>
    </Person>
    <Home>
    <HomeID>1</HomeID>
    <PersonID>12</PersonID>
    <HomeName>MyHom e</HomeName>
    </Home>
    </DsTester>


    What I want it to output is:
    <DsTester xmlns="http://tempuri.org/Dataset1.xsd">
    <Person>
    <PersonID>12</PersonID>
    <Name>John</Name>
    <Home>
    <HomeID>1</HomeID>
    <HomeName>MyHom e</HomeName>
    </Home>
    </Person>
    </DsTester>



    Is this possible, or am I going to have to roll my own?


    Thanks!!!
  • Cor Ligthert

    #2
    Re: Question about XMLDataDocument

    Mathew,

    I think that you are searching for this information (look at nested)



    I hope this helps?

    Cor

    "Mathew Relick" <ticars@yahoo.c om>
    [color=blue]
    > I'm relatively new to this sort of thing, so forgive me if this is
    > completely off base, but I'm having a problem getting the
    > XMLDataDocument to do what I need it to.
    >
    > I have a small test application that has a DataSet with two data
    > tables, Person and Home. I've setup Home as a child of Person. What
    > I want to do is to load data into these two tables, and then have the
    > data document create the xml with the child nodes (home) nested under
    > the parent node (person). Is this possible??? The code snippet I
    > have to load and output the xml is as follows:
    >
    > DsTester ds = new DsTester();
    > DsTester.Person DataTable pdt =
    > (DsTester.Perso nDataTable)ds.T ables["Person"];
    > DsTester.HomeDa taTable hdt =
    > (DsTester.HomeD ataTable)ds.Tab les["Home"];
    > pdt.AddPersonRo w(12,"John");
    > hdt.AddHomeRow( 1,pdt[0], "MyHome");
    > XmlDataDocument xdoc = new XmlDataDocument (ds);
    > System.Diagnost ics.Debug.Write Line(xdoc.Outer Xml);
    >
    >
    > What it outputs is:
    > <DsTester xmlns="http://tempuri.org/Dataset1.xsd">
    > <Person>
    > <PersonID>12</PersonID>
    > <Name>John</Name>
    > </Person>
    > <Home>
    > <HomeID>1</HomeID>
    > <PersonID>12</PersonID>
    > <HomeName>MyHom e</HomeName>
    > </Home>
    > </DsTester>
    >
    >
    > What I want it to output is:
    > <DsTester xmlns="http://tempuri.org/Dataset1.xsd">
    > <Person>
    > <PersonID>12</PersonID>
    > <Name>John</Name>
    > <Home>
    > <HomeID>1</HomeID>
    > <HomeName>MyHom e</HomeName>
    > </Home>
    > </Person>
    > </DsTester>
    >
    >
    >
    > Is this possible, or am I going to have to roll my own?
    >
    >
    > Thanks!!![/color]


    Comment

    Working...