Help with XML Output

S

SimeonD

Hi
I am outputting XML from a dataset.
So I have Employee section that looks like:
- <RiskDetails>
- <Business>
<Turnover>800000</Turnover>
- <Trade>
<TradeCode>M404</TradeCode>
<TradeDescription>Builder</TradeDescription>
<TradeOtherInfo>incl property developer</TradeOtherInfo>
</Trade>
- <Employees>
<NumberEmployed Category="111">1</NumberEmployed>
<NumberEmployed Category="006">2</NumberEmployed>
<NumberEmployed Category="119">3</NumberEmployed>
</Employees>



I want to add a WoodWorkers section to CARRisk, which I wanted to look like
the Employees section. But instead I get a line for each WoodWorker.
So I'd like to get
- <CARRisk>
<NumNewDwellings>15</NumNewDwellings>

- <WoodWorkers>
<WorkerDetail>Wood1</WorkerDetail>
<WorkerDetail>wood 2</WorkerDetail>
<WorkerDetail>wood 3</WorkerDetail>
<WorkerDetail>wood 4</WorkerDetail>
</WoodWorkers>
</CARRisk>

But instead I get the text below. Any idea what I must change?



- <CARRisk>
<NumNewDwellings>15</NumNewDwellings>

- <WoodWorkers CARRisk_Id="1">
<WoodWorkerID>1</WoodWorkerID>
- <Worker>
<WorkerDetail>Wood1</WorkerDetail>
<WoodWorkerId>1</WoodWorkerId>
</Worker>
- <Worker>
<WorkerDetail>wood 2</WorkerDetail>
<WoodWorkerId>1</WoodWorkerId>
</Worker>
- <Worker>
<WorkerDetail>wood 3</WorkerDetail>
<WoodWorkerId>1</WoodWorkerId>
</Worker>
- <Worker>
<WorkerDetail>wood 4</WorkerDetail>
<WoodWorkerId>1</WoodWorkerId>
</Worker>
</WoodWorkers>
</CARRisk>
 
S

Sanjib Sinha

Instead of trying Attributes I'd always like to use Elements Node, like your code can be written as
<CARRisk>

- <WoodWorkers>
<CARRisk_Id>1
- <Worker>
- <Worker>
- <Worker>
- <Worker>
...........
</CARRisk_Id>



SimeonD wrote:

Help with XML Output
18-Sep-09

H
I am outputting XML from a dataset
So I have Employee section that looks like
- <RiskDetails
- <Business
<Turnover>800000</Turnover
- <Trade
<TradeCode>M404</TradeCode
<TradeDescription>Builder</TradeDescription
<TradeOtherInfo>incl property developer</TradeOtherInfo
</Trade
- <Employees
<NumberEmployed Category="111">1</NumberEmployed
<NumberEmployed Category="006">2</NumberEmployed
<NumberEmployed Category="119">3</NumberEmployed
</Employees


I want to add a WoodWorkers section to CARRisk, which I wanted to look like
the Employees section. But instead I get a line for each WoodWorker
So I'd like to ge
- <CARRisk
<NumNewDwellings>15</NumNewDwellings

- <WoodWorkers
<WorkerDetail>Wood1</WorkerDetail
<WorkerDetail>wood 2</WorkerDetail
<WorkerDetail>wood 3</WorkerDetail
<WorkerDetail>wood 4</WorkerDetail
</WoodWorkers
</CARRisk

But instead I get the text below. Any idea what I must change


- <CARRisk
<NumNewDwellings>15</NumNewDwellings

- <WoodWorkers CARRisk_Id="1"
<WoodWorkerID>1</WoodWorkerID
- <Worker
<WorkerDetail>Wood1</WorkerDetail
<WoodWorkerId>1</WoodWorkerId
</Worker
- <Worker
<WorkerDetail>wood 2</WorkerDetail
<WoodWorkerId>1</WoodWorkerId
</Worker
- <Worker
<WorkerDetail>wood 3</WorkerDetail
<WoodWorkerId>1</WoodWorkerId
</Worker
- <Worker
<WorkerDetail>wood 4</WorkerDetail
<WoodWorkerId>1</WoodWorkerId
</Worker
</WoodWorkers
</CARRisk>

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorial...f-32b2d802ae17/wpf-datagrid-custom-pagin.aspx
 
S

Sanjib Sinha

The previous one was incomplete, here is the correct version....

<CARRisk>

- <WoodWorkers>
<CARRisk_Id>1
- <Worker>
- <Worker>
- <Worker>
- <Worker>
.........

</CARRisk_Id>



Sanjib Sinha wrote:

XML Query
28-Sep-09

Instead of trying Attributes I'd always like to use Elements Node, like your code can be written as
<CARRisk>

- <WoodWorkers>
<CARRisk_Id>1
- <Worker>
- <Worker>
- <Worker>
- <Worker>
...........
</CARRisk_Id>

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorial...f-32b2d802ae17/wpf-datagrid-custom-pagin.aspx
 
S

SimeonD

Thanks - could you show me what the schema would look like?

Mine looked like

<xs:element name="Wood" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="WorkerDetails"
minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent
msdata:ColumnName="Details_text" msdata:Ordinal="0">
<xs:extension base="xs:string">
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top