Datasets and XML

ctrlaltphreak

Member
Joined
Mar 28, 2008
Messages
10
Programming Experience
1-3
I am having a problem creating an XML file from a dataset.
The file I am creating is absolutely fine except for one problem. When I write the dataset out to xml it looks like this:
HTML:
<dataset>
	<category id="BD45S">
		<name>books</name>
	</category>
	<category id="BD56S">
		<name>CDs</name>
	</category>
	<product id="SS3" cat_id="BD45S">
		<name>Programming VB</name>
		<author>=CtrlAltPreak</author>
	</product>
	<product id="D45" cat_id="BD56S">
		<name>Definately Maybe</name>
		<artist>Oasis</artist>
	</product>
</dataset>

The problem is that I need all the category elements to be within one parent element(Categories) and all the product elements to be within another parent element(Products). Category and Product are two tables within my dataset.

Is their an easy solution to my problem?
What I need in the end is:
HTML:
<dataset>
	<categories>
		<category id="BD45S">
			<name>books</name>
		</category>
		<category id="BD56S">
			<name>CDs</name>
		</category>
	</categories>
	<products>
		<product id="SS3" cat_id="BD45S">
			<name>Programming VB</name>
			<author>=CtrlAltPreak</author>
		</product>
		<product id="D45" cat_id="BD56S">
			<name>Definately Maybe</name>
			<artist>Oasis</artist>
		</product>
	</products>
</dataset>
 
Last edited by a moderator:
might i suggest that you take the valid xml you want, and use XSD.EXE to create a dataset from it? i.e. work back from xml to dataset; you'll then see the flaw in your dataset and why your DS isnt generating the xml as neeeded..
 

Latest posts

Back
Top