{"id":304,"date":"2011-06-06T10:35:41","date_gmt":"2011-06-06T08:35:41","guid":{"rendered":"http:\/\/hen.co.za\/blog\/?p=304"},"modified":"2011-06-07T11:30:19","modified_gmt":"2011-06-07T09:30:19","slug":"xml-file-as-a-database-part-3","status":"publish","type":"post","link":"https:\/\/hen.co.za\/blog\/2011\/06\/xml-file-as-a-database-part-3\/","title":{"rendered":"Xml file as a database &#8211; part 3"},"content":{"rendered":"<p><a title=\"Xml file as a database part 2\" href=\"https:\/\/hen.co.za\/blog\/2011\/06\/xml-as-a-database-part-2\" target=\"_blank\">Last time<\/a> I stopped with the sample code how to produce a DataSet in code and then save and load it from a file. This time I&#8217;ll just continue with the &#8216;typed&#8217; DataSet version plus show what the output would look like. Interestingly, the output of both the untyped and typed versions looks (essentially) the same.<\/p>\n<p>First I&#8217;ll show how the Typed DataSet version works. Just to refresh the old minds &#8211; to create a Typed DataSet you use Visual Studio&#8217;s new template for a DataSet xsd and then use the designer to add tables, columns and relationships. Then in code you can do the following (the DataSet is named &#8216;DatabaseTest&#8217;):<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">DatabaseTest <\/span>dbt = <span style=\"color: #0000ff;\">new DatabaseTest<\/span>();<br \/>\n<span style=\"color: #0000ff;\">DatabaseTest.SurnameRow<\/span> surname = (<span style=\"color: #0000ff;\">DatabaseTest.SurnameRow<\/span>)dbt.Surname.NewRow();<br \/>\nsurname.Surname = &#8220;Henning&#8221;;<br \/>\nsurname.TS = <span style=\"color: #0000ff;\">DateTime<\/span>.Now;<br \/>\ndbt.Surname.AddSurnameRow(surname);<br \/>\nsurname = (DatabaseTest.SurnameRow)dbt.Surname.NewRow();<br \/>\nsurname.Surname = &#8220;Van Der Merwe&#8221;;<br \/>\nsurname.TS = <span style=\"color: #0000ff;\">DateTime<\/span>.Now;<br \/>\ndbt.Surname.AddSurnameRow(surname);<\/p>\n<p><span style=\"color: #0000ff;\">DatabaseTest.PersonRow<\/span> pa = (<span style=\"color: #0000ff;\">DatabaseTest.PersonRow<\/span>)dbt.Person.NewRow();<br \/>\npa.FirstName = &#8220;Daddy Koos&#8221;;<br \/>\npa.SurnameId = 1;<br \/>\npa.TS = <span style=\"color: #0000ff;\">DateTime<\/span>.Now;<br \/>\npa.YearOfBirth = 1945;<br \/>\ndbt.Person.AddPersonRow(pa);<\/p>\n<p><span style=\"color: #0000ff;\">DatabaseTest.PersonRow<\/span> ma = (<span style=\"color: #0000ff;\">DatabaseTest.PersonRow<\/span>)dbt.Person.NewRow();<br \/>\nma.FirstName = &#8220;Mommy Johanna&#8221;;<br \/>\nma.SurnameId = 2;<br \/>\nma.TS = <span style=\"color: #0000ff;\">DateTime<\/span>.Now;<br \/>\nma.YearOfBirth = 1950;<br \/>\ndbt.Person.AddPersonRow(ma);<\/p>\n<p><span style=\"color: #0000ff;\">DatabaseTest.PersonRow<\/span> guy = (<span style=\"color: #0000ff;\">DatabaseTest.PersonRow<\/span>)dbt.Person.NewRow();<br \/>\nguy.FirstName = &#8220;Little Koos&#8221;;<br \/>\nguy.SurnameId = 1;<br \/>\nguy.TS = <span style=\"color: #0000ff;\">DateTime<\/span>.Now;<br \/>\nguy.YearOfBirth = 1971;<br \/>\nguy.FatherID = 1;<br \/>\nguy.MotherID = 2;<br \/>\nguy.ChildNo = 1;<br \/>\ndbt.Person.AddPersonRow(guy);<\/p>\n<p><span style=\"color: #0000ff;\">if <\/span>(saveFileDialogXml.ShowDialog() == System.Windows.Forms.<span style=\"color: #0000ff;\">DialogResult<\/span>.OK)<br \/>\n{<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">if<\/span> (System.IO.<span style=\"color: #0000ff;\">File<\/span>.Exists(saveFileDialogXml.FileName))<\/p>\n<p style=\"padding-left: 60px;\">System.IO.<span style=\"color: #0000ff;\">File<\/span>.Delete(saveFileDialogXml.FileName);<\/p>\n<p style=\"padding-left: 30px;\">dbt.WriteXml(saveFileDialogXml.FileName, <span style=\"color: #0000ff;\">XmlWriteMode<\/span>.WriteSchema);<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #800000;\">var <\/span>people = (<span style=\"color: #800000;\">from<\/span> p <span style=\"color: #800000;\">in <\/span>dbt.Person<br \/>\n<span style=\"color: #800000;\">join <\/span>s in dbt.Surname <span style=\"color: #800000;\">on <\/span>p.SurnameId <span style=\"color: #800000;\">equals <\/span>s.Id<br \/>\n<span style=\"color: #800000;\">select<\/span> new<br \/>\n{<\/p>\n<p style=\"padding-left: 60px;\">PersonId = p.Id,<br \/>\nFirstName = p.FirstName,<br \/>\nSurname = s.Surname<\/p>\n<p style=\"padding-left: 30px;\">});<br \/>\n<span style=\"color: #0000ff;\">StringBuilder <\/span>sb = <span style=\"color: #0000ff;\">new StringBuilder<\/span>();<br \/>\n<span style=\"color: #0000ff;\">foreach <\/span>(<span style=\"color: #800000;\">var<\/span> p <span style=\"color: #800000;\">in <\/span>people)<br \/>\n{<\/p>\n<p style=\"padding-left: 60px;\">sb.AppendLine(<span style=\"color: #0000ff;\">string<\/span>.Format(&#8220;{0} {1}&#8221;, p.FirstName, p.Surname));<\/p>\n<p style=\"padding-left: 30px;\">}<br \/>\nMessageBox.Show(sb.ToString());<\/p>\n<p style=\"padding-left: 30px;\">System.Diagnostics.<span style=\"color: #0000ff;\">Process <\/span>pro = <span style=\"color: #0000ff;\">new <\/span>System.Diagnostics.<span style=\"color: #0000ff;\">Process<\/span>();<br \/>\npro.StartInfo = <span style=\"color: #0000ff;\">new<\/span> System.Diagnostics.<span style=\"color: #0000ff;\">ProcessStartInfo<\/span>(System.IO.<span style=\"color: #0000ff;\">Path<\/span>.Combine(System.<span style=\"color: #0000ff;\">Environment<\/span>.GetFolderPath(Environment.SpecialFolder.System), &#8220;notepad.exe&#8221;));<br \/>\npro.StartInfo.Arguments = &#8220;\\&#8221;&#8221; + saveFileDialogXml.FileName + &#8220;\\&#8221;&#8221;;<br \/>\npro.Start();<\/p>\n<p>}<\/p><\/blockquote>\n<p>This provides the same functionality as before. The output looks something like this (sorry, I&#8217;m a bit lazy to format\/indend the output too much now):<\/p>\n<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; standalone=&#8221;yes&#8221;?&gt;<br \/>\n&lt;DatabaseTest xmlns=&#8221;http:\/\/tempuri.org\/DatabaseTest.xsd&#8221;&gt;<br \/>\n&lt;xs:schema id=&#8221;DatabaseTest&#8221; targetNamespace=&#8221;http:\/\/tempuri.org\/DatabaseTest.xsd&#8221; xmlns:mstns=&#8221;http:\/\/tempuri.org\/DatabaseTest.xsd&#8221; xmlns=&#8221;http:\/\/tempuri.org\/DatabaseTest.xsd&#8221; xmlns:xs=&#8221;http:\/\/www.w3.org\/2001\/XMLSchema&#8221; xmlns:msdata=&#8221;urn:schemas-microsoft-com:xml-msdata&#8221; attributeFormDefault=&#8221;qualified&#8221; elementFormDefault=&#8221;qualified&#8221;&gt;<br \/>\n&lt;xs:element name=&#8221;DatabaseTest&#8221; msdata:IsDataSet=&#8221;true&#8221; msdata:UseCurrentLocale=&#8221;true&#8221;&gt;<br \/>\n&lt;xs:complexType&gt;<br \/>\n&lt;xs:choice minOccurs=&#8221;0&#8243; maxOccurs=&#8221;unbounded&#8221;&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Person<\/span>&#8220;&gt;<br \/>\n&lt;xs:complexType&gt;<br \/>\n&lt;xs:sequence&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Id<\/span>&#8221; msdata:AutoIncrement=&#8221;true&#8221; msdata:AutoIncrementSeed=&#8221;1&#8243; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">FirstName<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">string<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">SurnameId<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Description<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">string<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">YearOfBirth<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">MonthOfBirth<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">DayOfBirth<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">TS<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">dateTime<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">FatherID<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">MotherID<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">PlaceOfBirthId<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">YearOfDeath<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">MonthOfDeath<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">DayOfDeath<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">PlaceOfDeathId<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">GenealogicalNo<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">string<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">ChildNo<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; default=&#8221;0&#8243; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">ProgenitorCode<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">string<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">IsProgenitor<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">boolean<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;\/xs:sequence&gt;<br \/>\n&lt;\/xs:complexType&gt;<br \/>\n&lt;\/xs:element&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Surname<\/span>&#8220;&gt;<br \/>\n&lt;xs:complexType&gt;<br \/>\n&lt;xs:sequence&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Id<\/span>&#8221; msdata:AutoIncrement=&#8221;true&#8221; msdata:AutoIncrementSeed=&#8221;1&#8243; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Surname<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">string<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">TS<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">dateTime<\/span>&#8221; \/&gt;<br \/>\n&lt;\/xs:sequence&gt;<br \/>\n&lt;\/xs:complexType&gt;<br \/>\n&lt;\/xs:element&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Place<\/span>&#8220;&gt;<br \/>\n&lt;xs:complexType&gt;<br \/>\n&lt;xs:sequence&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Id<\/span>&#8221; msdata:AutoIncrement=&#8221;true&#8221; msdata:AutoIncrementSeed=&#8221;1&#8243; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Place<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">string<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">TS<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">dateTime<\/span>&#8221; \/&gt;<br \/>\n&lt;\/xs:sequence&gt;<br \/>\n&lt;\/xs:complexType&gt;<br \/>\n&lt;\/xs:element&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Marriage<\/span>&#8220;&gt;<br \/>\n&lt;xs:complexType&gt;<br \/>\n&lt;xs:sequence&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">Id<\/span>&#8221; msdata:AutoIncrement=&#8221;true&#8221; msdata:AutoIncrementSeed=&#8221;1&#8243; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">No<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; default=&#8221;0&#8243; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">HusbandId<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">WifeId<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">YearOfMarriage<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">MonthOfMarriage<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">DayOfMarriage<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">unsignedByte<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">PlaceOfMarriageId<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;xs:element name=&#8221;<span style=\"color: #0000ff;\">YearOfDivorce<\/span>&#8221; type=&#8221;xs:<span style=\"color: #0000ff;\">int<\/span>&#8221; minOccurs=&#8221;0&#8243; \/&gt;<br \/>\n&lt;\/xs:sequence&gt;<br \/>\n&lt;\/xs:complexType&gt;<br \/>\n&lt;\/xs:element&gt;<br \/>\n&lt;\/xs:choice&gt;<br \/>\n&lt;\/xs:complexType&gt;<br \/>\n&lt;xs:unique name=&#8221;Constraint1&#8243; msdata:PrimaryKey=&#8221;true&#8221;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Person&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:Id&#8221; \/&gt;<br \/>\n&lt;\/xs:unique&gt;<br \/>\n&lt;xs:unique name=&#8221;Surname_Constraint1&#8243; msdata:ConstraintName=&#8221;Constraint1&#8243; msdata:PrimaryKey=&#8221;true&#8221;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Surname&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:Id&#8221; \/&gt;<br \/>\n&lt;\/xs:unique&gt;<br \/>\n&lt;xs:unique name=&#8221;Constraint2&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Surname&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:Surname&#8221; \/&gt;<br \/>\n&lt;\/xs:unique&gt;<br \/>\n&lt;xs:unique name=&#8221;Place_Constraint1&#8243; msdata:ConstraintName=&#8221;Constraint1&#8243; msdata:PrimaryKey=&#8221;true&#8221;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Place&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:Id&#8221; \/&gt;<br \/>\n&lt;\/xs:unique&gt;<br \/>\n&lt;xs:unique name=&#8221;Place_Constraint2&#8243; msdata:ConstraintName=&#8221;Constraint2&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Place&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:Place&#8221; \/&gt;<br \/>\n&lt;\/xs:unique&gt;<br \/>\n&lt;xs:unique name=&#8221;Marriage_Constraint1&#8243; msdata:ConstraintName=&#8221;Constraint1&#8243; msdata:PrimaryKey=&#8221;true&#8221;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Marriage&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:Id&#8221; \/&gt;<br \/>\n&lt;\/xs:unique&gt;<br \/>\n&lt;xs:keyref name=&#8221;FK_Person_Marriage&#8221; refer=&#8221;Constraint1&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Marriage&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:HusbandId&#8221; \/&gt;<br \/>\n&lt;\/xs:keyref&gt;<br \/>\n&lt;xs:keyref name=&#8221;FK_Person_Marriage1&#8243; refer=&#8221;Constraint1&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Marriage&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:WifeId&#8221; \/&gt;<br \/>\n&lt;\/xs:keyref&gt;<br \/>\n&lt;xs:keyref name=&#8221;FK_Person_Person1&#8243; refer=&#8221;Constraint1&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Person&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:MotherID&#8221; \/&gt;<br \/>\n&lt;\/xs:keyref&gt;<br \/>\n&lt;xs:keyref name=&#8221;FK_Person_Surname&#8221; refer=&#8221;Surname_Constraint1&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Person&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:SurnameId&#8221; \/&gt;<br \/>\n&lt;\/xs:keyref&gt;<br \/>\n&lt;xs:keyref name=&#8221;FK_Place_Person&#8221; refer=&#8221;Place_Constraint1&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Person&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:PlaceOfBirthId&#8221; \/&gt;<br \/>\n&lt;\/xs:keyref&gt;<br \/>\n&lt;xs:keyref name=&#8221;FK_Person_Person&#8221; refer=&#8221;Constraint1&#8243;&gt;<br \/>\n&lt;xs:selector xpath=&#8221;.\/\/mstns:Person&#8221; \/&gt;<br \/>\n&lt;xs:field xpath=&#8221;mstns:FatherID&#8221; \/&gt;<br \/>\n&lt;\/xs:keyref&gt;<br \/>\n&lt;\/xs:element&gt;<br \/>\n&lt;\/xs:schema&gt;<\/p>\n<p>&lt;Person&gt;<br \/>\n&lt;Id&gt;1&lt;\/Id&gt;<br \/>\n&lt;FirstName&gt;Daddy Koos&lt;\/FirstName&gt;<br \/>\n&lt;SurnameId&gt;1&lt;\/SurnameId&gt;<br \/>\n&lt;YearOfBirth&gt;1945&lt;\/YearOfBirth&gt;<br \/>\n&lt;TS&gt;2011-06-06T09:15:58.0021555+02:00&lt;\/TS&gt;<br \/>\n&lt;ChildNo&gt;0&lt;\/ChildNo&gt;<br \/>\n&lt;\/Person&gt;<br \/>\n&lt;Person&gt;<br \/>\n&lt;Id&gt;2&lt;\/Id&gt;<br \/>\n&lt;FirstName&gt;Mamma Johanna&lt;\/FirstName&gt;<br \/>\n&lt;SurnameId&gt;2&lt;\/SurnameId&gt;<br \/>\n&lt;YearOfBirth&gt;1950&lt;\/YearOfBirth&gt;<br \/>\n&lt;TS&gt;2011-06-06T09:52:51.4151521+02:00&lt;\/TS&gt;<br \/>\n&lt;ChildNo&gt;0&lt;\/ChildNo&gt;<br \/>\n&lt;\/Person&gt;<br \/>\n&lt;Person&gt;<br \/>\n&lt;Id&gt;3&lt;\/Id&gt;<br \/>\n&lt;FirstName&gt;Little Koos&lt;\/FirstName&gt;<br \/>\n&lt;SurnameId&gt;1&lt;\/SurnameId&gt;<br \/>\n&lt;YearOfBirth&gt;1971&lt;\/YearOfBirth&gt;<br \/>\n&lt;TS&gt;2011-06-06T09:52:51.4151521+02:00&lt;\/TS&gt;<br \/>\n&lt;FatherID&gt;1&lt;\/FatherID&gt;<br \/>\n&lt;MotherID&gt;2&lt;\/MotherID&gt;<br \/>\n&lt;ChildNo&gt;1&lt;\/ChildNo&gt;<br \/>\n&lt;\/Person&gt;<\/p>\n<p>&lt;Surname&gt;<br \/>\n&lt;Id&gt;1&lt;\/Id&gt;<br \/>\n&lt;Surname&gt;Henning&lt;\/Surname&gt;<br \/>\n&lt;TS&gt;2011-06-06T09:15:57.9771555+02:00&lt;\/TS&gt;<br \/>\n&lt;\/Surname&gt;<br \/>\n&lt;Surname&gt;<br \/>\n&lt;Id&gt;2&lt;\/Id&gt;<br \/>\n&lt;Surname&gt;Van Der Merwe&lt;\/Surname&gt;<br \/>\n&lt;TS&gt;2011-06-06T09:52:51.4121521+02:00&lt;\/TS&gt;<br \/>\n&lt;\/Surname&gt;<\/p>\n<p>&lt;\/DatabaseTest&gt;<\/p><\/blockquote>\n<p>As you can see the xsd is actually embedded inside the xml file. This is helpful to see the structure of the data.<\/p>\n<h2>Next step<\/h2>\n<p>The next step is to create a Data Access Layer because dealing with a DataSet directly in code is so&#8230; old fashioned&#8230; and so on. Stay tuned for the next iteration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last time I stopped with the sample code how to produce a DataSet in code and then save and load it from a file. This time I&#8217;ll just continue with the &#8216;typed&#8217; DataSet version plus show what the output would &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/hen.co.za\/blog\/2011\/06\/xml-file-as-a-database-part-3\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[7,9,35,37,36,303,34],"class_list":["post-304","post","type-post","status-publish","format-standard","hentry","category-development","tag-net","tag-code","tag-data","tag-database","tag-dataset","tag-development","tag-xml"],"_links":{"self":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/comments?post=304"}],"version-history":[{"count":7,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/304\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/304\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/media?parent=304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/categories?post=304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/tags?post=304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}