Re: Saving dataset as nested XML

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Paul Eden (a_at_b.com)
Date: 10/05/04


Date: Tue, 05 Oct 2004 12:34:34 GMT

Essentially, the schema creates 2 relations (in my case)

Customers.Customer_ID --> Addresses.Customer_ID

and

Addresses.Addresses_ID --> Address.Addresses_ID

The following code created my output as nested:

         With CustomerData
 
.ReadXmlSchema(IO.Path.GetDirectoryName(Application.ExecutablePath) &
"\Customer.xsd")
             .Relations.Clear()
             .Relations.Add("CustomerToAddresses",
.Tables(0).Columns("CustomerID"), .Tables(1).Columns("CustomerID"))
             .Relations(0).Nested = True

             .Relations.Add("AddressesToAddress",
.Tables(1).Columns("AddressesID"), .Tables(2).Columns("AddressesID"))
             .Relations(1).Nested = True
        End With

Where CustomerID and AddressesID are my new additional fields.

I also tried re-creating the relationships using the original fieldnames
(with the '_', which are hidden fields) but once again my output was wrong.

The code should paste driect into IDE without problems.

Paul

Richard L Rosenheim wrote:

> Can you please provide more details of how you got it to work?
>
> I too have confirmed that the relationships are being created by checking
> the Relations. My child tables, in additional to an unique autonumber ID
> field, also contains an ID field containing the parent ID. All these fields
> are defined as of type "long". And, IsNested is defined as true in the
> relation tags in the resulting XML Schema.
>
> Richard Rosenheim
>
>
> "Paul Eden" <a@b.com> wrote in message
> news:Xzg8d.202$y%3.31@newsfe1-win.ntli.net...
>
>>Richard
>>
>>I been fidling with this for most of the day. My Schema, when loaded
>>into the dataset, generates all the relevent relationships (this I did
>>not realise, going on the lack of correct output), with nested set to
>>true (via interogating the dataset).
>>I finally too the step of clearing the Relations collection on the data
>>set, and re-creating them manually (which was a bit of a bugger,
>>becausae I had to go through and add ID fields for the relationships)...
>>BUT.. my ouput is now nested.
>>
>>A long winded and painfull fix, but it's the only one I found - hope an
>>MS bod is reading - would be interesting to hear thier side.
>>
>>
>>Paul
>>
>>Richard L Rosenheim wrote:
>>
>>>You are correct -- having IsNested="true" doesn't seems to make any
>>>difference what-so-ever. In the XML file that I attached to my previous
>>>post, it contained IsNested="true" attributes for the keys.
>>>
>>>Richard Rosenheim
>>>
>>>
>>>
>>>"Paul Eden" <a@b.com> wrote in message
>>>news:0Rb8d.56$hs3.38@newsfe5-win.ntli.net...
>>>
>>>
>>>>Richard
>>>>
>>>>I'm having much the same issue. In one post I read that you have to set
>>>>up the relationships in the dataset and have the relationship flaged as
>>>>Nested=True, but this did not create the desired output either..
>>>>actually, it made no difference whatsoever. It might make a difference
>>>>for you?
>>>>
>>>>I can post my schema and code if required.
>>>>
>>>>
>>>>Paul
>>>>
>>>>Richard L Rosenheim wrote:
>>>>
>>>>
>>>>>I've been trying to save a dataset to a XML file and have the child
>
> data
>
>>>>>nested under the parent data. Everything I have tried so far results
>
> in
>
>>>all
>>>
>>>
>>>>>the records from the parent table being listed followed by all the rows
>>>
>>>of
>>>
>>>
>>>>>the child table.
>>>>>
>>>>>As a result of previous posts, I currently created my tables based upon
>>>
>>>the
>>>
>>>
>>>>>steps outlined in
>>>>>
>>>
>>>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingnestedrelationshipsinxmlschemas.asp
>
>>>>>For my example, I created three tables: Contacts, Telephones and
>>>
>>>Addresses
>>>
>>>
>>>>>where Telephones and Addresses are defined as children of Contacts. In
>>>
>>>the
>>>
>>>
>>>>>resulting schema, Telephones and Addresses are nested within Contacts.
>>>
>>>But
>>>
>>>
>>>>>the actual data is not.
>>>>>
>>>>>What I'm looking to achieve is to have the data outputted in a format
>>>
>>>like:
>>>
>>>
>>>>> <Contacts>
>>>>> <Addresses>
>>>>> </Addresses>
>>>>> <Telephones>
>>>>> </Telephones>
>>>>> <Telephones>
>>>>> </Telephones>
>>>>> </Contacts>
>>>>>instead of the structure I'm getting:
>>>>> <Contacts>
>>>>> </Contacts>
>>>>> <Contacts>
>>>>> </Contacts>
>>>>> <Addresses>
>>>>> </Addresses>
>>>>> <Telephones>
>>>>> </Telephones>
>>>>> <Telephones>
>>>>> </Telephones>
>>>>>
>>>>>Anyone have any ideas? Attached is the resulting XML file I'm getting,
>>>
>>>with
>>>
>>>
>>>>>schema. I'm using Visual Studio 2003.
>>>>>
>>>>>TIA,
>>>>>
>>>>>Richard Rosenheim
>>>>>
>>>>>
>>>
>>>
>>>
>
>



Relevant Pages

  • Re: Saving dataset as nested XML
    ... > In my schema, my child is nested but I only received the duplicate ... >> table, your code worked, and the resulting XML file had the data nested. ... >> resulting schema from the file, and pasted it back into the XSD Editor. ... >> Richard Rosenheim ...
    (microsoft.public.dotnet.xml)
  • Re: Saving dataset as nested XML
    ... not realise, going on the lack of correct output), with nested set to ... > Richard Rosenheim ... it made no difference whatsoever. ... >>I can post my schema and code if required. ...
    (microsoft.public.dotnet.xml)
  • Re: 2003 R2 version question
    ... I know 31 in the forest root is the correct version, ... child is at 30. ... sounds like there is a problem with your schema replication though. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Is the following question possible to do in .Net
    ... Master Dataset ... Note that the schema of the master set is not the same as schema of ... child but child schema is contained in the master schema. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Schema: Relationship expected on Error
    ... I looked at your schema and I wanted to clarify one thing first:the child ... every child element that is mapped to a different table than the parent. ... > XML) to be informative in helping me with XML. ... > error 'Schema: relationship expected on 'PSECP200'' when executing my script. ...
    (microsoft.public.sqlserver.xml)