Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2013 Cycle through one XML file and find values in another XML and conbine both

$
0
0
Well I have spent a couple of days on this problem and I can't seem to find the answer "out there" so I've come here:)

I am working on a program that takes one flat form text file and converts it into two XML files, one called Families and the other call Individuals. The first one only hold ID numbers relating to the second one. My task is to create a third XML file that contains all the information I need to work with.

Example Date Families.xml

<?xml version="1.0" encoding="utf-8"?>
<Families>
<Family>
<FamilyID>2</FamilyID>
<Husband>3</Husband>
<Wife>4</Wife>
<Child>5</Child>
<Child>133</Child>
<Child>137</Child>
<Child>138</Child>
<Child>139</Child>
<Child>140</Child>
<Child>141</Child>
<Child>145</Child>
<Children>9</Children>
</Family>
<Family>
<FamilyID>3</FamilyID>
<Husband>5</Husband>
<Wife>6</Wife>
<Child>9</Child>
<Child>10</Child>
<Child>11</Child>
<Child>22</Child>
<Child>89</Child>
<Child>90</Child>
<Child>91</Child>
<Child>92</Child>
<Child>93</Child>
<Children>10</Children>
</Family>
</Families>

Example individals.xml

<Individuals>
<Individual>
<ID>3</ID>
<ForeNames>William Brett</ForeNames>
<Surname>PITT</Surname>
<Sex>Male</Sex>
<DOB>ABT 1796</DOB>
<PlaceOfBirth>Colchester, Essex, England</PlaceOfBirth>
<DOD>31 AUG 1845</DOD>
<PlaceOfDeath>Saint Giles, Colchester, Essex, England</PlaceOfDeath>
<Wife>0</Wife>
<Husband>2</Husband>
<Son>68</Son>
<Daughter>0</Daughter>
</Individual>
<Individual>
<ID>4</ID>
<ForeNames>Susan</ForeNames>
<Surname>BLUNDELL</Surname>
<Sex>Female</Sex>
<DOB>1796</DOB>
<PlaceOfBirth>Bury St Edmunds, Suffolk, England</PlaceOfBirth>
<DOD>24 JUN 1869</DOD>
<PlaceOfDeath>Colchester, Essex</PlaceOfDeath>
<Wife>2</Wife>
<Husband>0</Husband>
</Individual>
<Individual>
<ID>5</ID>
<ForeNames>William Brett</ForeNames>
<Surname>PITT</Surname>
<Sex>Male</Sex>
<DOB>ABT 1818</DOB>
<PlaceOfBirth>Colchester, Essex, England</PlaceOfBirth>
<DOD>7 JAN 1888</DOD>
<PlaceOfDeath>Colchester, Essex, England</PlaceOfDeath>
<Wife>0</Wife>
<Husband>3</Husband>
<Wife>0</Wife>
<Husband>5</Husband>
<Son>2</Son>
<Daughter>0</Daughter>
</Individual>
</Individuals>

There are two ways of referencing the information I can use to create a new XML file. I can read either or both of them but I haven't found a way to step through them to capture the individual information. For example, I could read through the family.xml file and find that Individual number 3 is the Husband in FamilyID 2 but how can I then search through the individuals.xml to locate the individual with an id of 3 and pull out the information relating to that person to write to a new file. In UML terms...

Open Families.xml
Read the XML file to the first family record
Capture the FamilyID
Capture the Husband ID number

Open the Individuals.xml
while husbanded not found
Read the next record to find the Husbands ID number
Wend
Once found capture all the information for that individual

Loop
Reutrn to find Wife's ID

Loop
Return to find each child's ID

Create new XML file
Write in all the family details

Close everything

Am I on the right tracks or is there an easier way of achieving this.

THanks for looking and have a great Christmas!!

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>