Forum Moderators: open
Can anyone describe how this should be done? I can post xsd and xml if that would help.
Thanks,
Ross
Here's the xml in its entirety. Enrollees is suposed to be a child of Training Class, but it doesn't look like it is to me. (I also included the xsd genned by vs.net and my vb code further down).
Thanks
Ross
<TrainingClass1 xmlns="http://tempuri.org/TrainingClass.xsd">
<Enrollees>
<ClassID>001</ClassID>
<UserID>walsmwr</UserID>
<ConfirmedInd>false</ConfirmedInd>
</Enrollees>
<Enrollees>
<ClassID>001</ClassID>
<UserID>priceji</UserID>
<ConfirmedInd>true</ConfirmedInd>
</Enrollees>
<Enrollees>
<ClassID>002</ClassID>
<UserID>xwalsmwr</UserID>
<ConfirmedInd>false</ConfirmedInd>
</Enrollees>
<Enrollees>
<ClassID>002</ClassID>
<UserID>xpriceji</UserID>
<ConfirmedInd>true</ConfirmedInd>
</Enrollees>
<TrainingClass>
<ClassID>001</ClassID>
</TrainingClass>
<TrainingClass>
<ClassID>002</ClassID>
</TrainingClass>
</TrainingClass1>
NOW HERE IS THE XSD
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TrainingClass" targetNamespace="http://tempuri.org/TrainingClass.xsd" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/TrainingClass.xsd" xmlns:mstns="http://tempuri.org/TrainingClass.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="TrainingClass1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Enrollees">
<xs:complexType>
<xs:sequence>
<xs:element name="ClassID" type="xs:string" minOccurs="0" />
<xs:element name="UserID" type="xs:string" minOccurs="0" />
<xs:element name="ConfirmedInd" type="xs:boolean" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TrainingClass">
<xs:complexType>
<xs:sequence>
<xs:element name="ClassID" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="TrainingClassKey1">
<xs:selector xpath=".//mstns:TrainingClass" />
<xs:field xpath="mstns:ClassID" />
</xs:key>
<xs:keyref name="TrainingClassEnrollees" refer="TrainingClassKey1" msdata:DeleteRule="Cascade" msdata:IsNested="true">
<xs:selector xpath=".//mstns:Enrollees" />
<xs:field xpath="mstns:ClassID" />
</xs:keyref>
<xs:key name="TrainingClassKey2">
<xs:selector xpath=".//mstns:Enrollees" />
<xs:field xpath="mstns:ClassID" />
<xs:field xpath="mstns:UserID" />
</xs:key>
<xs:key name="TrainingClass1Key1">
<xs:selector xpath=".//mstns:Enrollees" />
<xs:field xpath="mstns:ClassID" />
</xs:key>
</xs:element>
</xs:schema>
AND HERE IS THE VB.NET
Dim ds As New DataSet()
Dim dr, childDR As DataRow
Dim i As Integer
ds.ReadXml(Me.MapPath("MyXML.xml"))
For i = 0 To ds.Tables("TrainingClass").Rows.Count - 1
dr = ds.Tables("TrainingClass").Rows(i)
Response.Write(dr.Item(0))
For Each childDR In dr.GetChildRows("TrainingClassEnrollees")
Response.Write("*")
Response.Write(childDR.Item(0))
Response.Write(childDR.Item(1))
Next
Next
Try adding this call:
[msdn.microsoft.com...]