Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Please help with getting the right structure from dataset using GetXML()

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 3/9/2009 8:24:00 AM
<emailhelen@g...> wrote in message 
news:8329a8e3-b0eb-4f8a-a03c-7a939176c6fa@l......
> Hi everyone,
>
> I need your help getting my getXML method to function the way I need
> it to. I have a stored procedure that returns data into a dataset (I
> am using VB.NET). I use getXML with dataset and I get the following
> result:
>
> <NewDataSet>
> <Table>
>   <StudentFirstName>John</StudentFirstName>
>   <StudentMiddleName>J</StudentMiddleName>
>   <StudentLastName>Smith</StudentLastName>
>   <StudentAddressType>Permanent</StudentAddressType>
>   <StudentAddressLine1>123 Some Rd</StudentAddressLine1>
>   <StudentAddressLine2 />
>   <StudentAddressLine3 />
>   <StudentAddressLine4 />
>   <StudentAddressCity>New Town</StudentAddressCity>
>   <StudentAddressState>NJ</StudentAddressState>
>   <StudentAddressPostalCode>12345</StudentAddressPostalCode>
>   <StudentAddressCounty />
>   <StudentAddressCountry>United States</StudentAddressCountry>
>   <StudentHomePhoneNumber>1234567890</StudentHomePhoneNumber>
>   <StudentCellPhoneNumber>1234567890</StudentCellPhoneNumber>
>   <Parent1FirstName>Jane</Parent1FirstName>
>   <Parent1MiddleName />
>   <Parent1LastName>Smith</Parent1LastName>
>   <Parent1HomePhoneNumber>1234567890</Parent1HomePhoneNumber>
>   <Parent1WorkPhoneNumber />
>   <Parent1EmailType>Personal</Parent1EmailType>
>   <Parent1EmailAddress>john@m...</Parent1EmailAddress>
>   <Parent2FirstName>John Sr</Parent2FirstName>
>   <Parent2MiddleName />
>   <Parent2LastName>Smith</Parent2LastName>
>   <Parent2HomePhoneNumber>1234567890</Parent2HomePhoneNumber>
>   <Parent2WorkPhoneNumber />
>   <Parent2EmailType>Personal</Parent2EmailType>
>   <Parent2EmailAddress>johnsr@m...</Parent2EmailAddress>
> </Table>
> </NewDataSet>
>
> Which is all fine and good but what I really need to get is the
> following:
> <Data>
>   <StudentData>
>       <StudentFirstName>John</StudentFirstName>
>       <StudentMiddleName>J</StudentMiddleName>
>       <StudentLastName>Smith</StudentLastName>
>       <StudentAddressType>Permanent</StudentAddressType>
>       <StudentAddressLine1>123 Some Rd</StudentAddressLine1>
>       <StudentAddressLine2 />
>       <StudentAddressLine3 />
>       <StudentAddressLine4 />
>       <StudentAddressCity>New Town</StudentAddressCity>
>       <StudentAddressState>NJ</StudentAddressState>
>       <StudentAddressPostalCode>12345</StudentAddressPostalCode>
>       <StudentAddressCounty />
>       <StudentAddressCountry>United States</StudentAddressCountry>
>       <StudentHomePhoneNumber>1234567890</StudentHomePhoneNumber>
>       <StudentCellPhoneNumber>1234567890</StudentCellPhoneNumber>
>       </StudentData>
>   <ParentData>
>       <Parent>
>               <Parent1FirstName>Jane</Parent1FirstName>
>               <Parent1MiddleName />
>               <Parent1LastName>Smith</Parent1LastName>
>               <Parent1HomePhoneNumber>1234567890</
> Parent1HomePhoneNumber>
>               <Parent1WorkPhoneNumber />
>               <Parent1EmailType>Personal</Parent1EmailType>
>               <Parent1EmailAddress>john@m...</
> Parent1EmailAddress>
>       </Parent>
>       <Parent>
>               <Parent2FirstName>John Sr</Parent2FirstName>
>               <Parent2MiddleName />
>               <Parent2LastName>Smith</Parent2LastName>
>               <Parent2HomePhoneNumber>1234567890</
> Parent2HomePhoneNumber>
>               <Parent2WorkPhoneNumber />
>               <Parent2EmailType>Personal</Parent2EmailType>
>               <Parent2EmailAddress>johnsr@m...</
> Parent2EmailAddress>
>       </Parent>
>   </ParentData>
> </Data>
>
> Can someone please help me figure out how to impose this structure
> upon the XML I get from the dataset returned by my stored procedure?
> Thanks in advance for your anticipated assistance!

I don't often use datasets in this way but I can suggest two options:
* Don't use a dataset, just use SQL Server's XML methods to return the XML 
directly (this assumes a SQL Server back end)
* Transform the data after retrieving it from the dataset using XSLT

If either of those suits you let us know which, and what your database is if 
option one, and we'll try to assist.

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name 



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent