# I am using the Perl module XML::Simple to reformat the XML file that contains the 1900 census data. The programs knows which file to retrieve because it was passed from the More… link above, and was determined by the getDefaults subroutine above. 

use XML::Simple;

my $xmlref;
my $xmlref = XMLin("/home3/pullman/sites/pullman-museum.org/html/XML/$xmlFile");

# Is the actual file name and path



##### houseInformation #####
$aptNumber = $xmlref->{houseInformation}->{aptNumber};
$address = $xmlref->{houseInformation}->{address};
$street = $xmlref->{houseInformation}->{street};
$dwellingNumber = $xmlref->{houseInformation}->{dwellingNumber};

##### personalInformation #####
$familiesNumber = $xmlref->{personalInformation}->{familiesNumber};
$lastName = $xmlref->{personalInformation}->{lastName};
$firstName = $xmlref->{personalInformation}->{firstName};
$relation = $xmlref->{personalInformation}->{relation};
$race = $xmlref->{personalInformation}->{race};
$sex = $xmlref->{personalInformation}->{sex};
$dobMonth = $xmlref->{personalInformation}->{dobMonth};
$dobYear = $xmlref->{personalInformation}->{dobYear};
$dob = $dobMonth . " " . $dobYear;
$age = $xmlref->{personalInformation}->{age};
$maritalStatus = $xmlref->{personalInformation}->{maritalStatus};
$yearsMarried = $xmlref->{personalInformation}->{yearsMarried};
$motherOf = $xmlref->{personalInformation}->{motherOf};
$childrenLiving = $xmlref->{personalInformation}->{childrenLiving};

##### ancestry #####
$placeOfBirth = $xmlref->{ancestry}->{placeOfBirth};
$placeOfBirthFather = $xmlref->{ancestry}->{placeOfBirthFather};
$placeOfBirthMother = $xmlref->{ancestry}->{placeOfBirthMother};

##### immigrationStatus #####
$immigrated = $xmlref->{immigrationStatus}->{immigrated};
$yearsInUS = $xmlref->{immigrationStatus}->{yearsInUS};
$naturalized = $xmlref->{immigrationStatus}->{naturalized};

##### educationAndOccupation #####
$occupation = $xmlref->{educationAndOccupation}->{occupation};
$monthsUnemployed = $xmlref->{educationAndOccupation}->{monthsUnemployed};
$monthsAtSchool = $xmlref->{educationAndOccupation}->{monthsAtSchool};
$read = $xmlref->{educationAndOccupation}->{read};
$write = $xmlref->{educationAndOccupation}->{write};
$english = $xmlref->{educationAndOccupation}->{english};

##### housingStatus #####
$ownOrRent = $xmlref->{housingStatus}->{ownOrRent};
$ownOrMortgage = $xmlref->{housingStatus}->{ownOrMortgage};

##### censusInformation #####
$pageNumber = $xmlref->{censusInformation}->{pageNumber};
$lineNumber = $xmlref->{censusInformation}->{lineNumber};
$reelNumber = $xmlref->{censusInformation}->{reelNumber};
$notes = $xmlref->{censusInformation}->{notes};

	if ($firstName ne "") { $nameOfPerson = $lastName . ", " . $firstName }
	else { $nameOfPerson = $lastName }
	
	$aptNumber =~ s/Room//g;
	if ($aptNumber ne "") { $nameOfPerson = $nameOfPerson . " Room " . $aptNumber }


print "Content-type: text/html\n\n";
print <<EOF;
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
$stylesheetlink
<title>House Histories. $year Census Information for $nameOfPerson</title>
</head>
<body>

<table>
  <tr id="topBannerRow1">
    <td class="topbannersides"><img src="/images/phhpicon.gif" alt="The Pullman House History Project" / width="75" height="46"></td>
    <td class="topbannermiddle"><img src="/images/logo2.GIF" alt="Welcome to the Pullman Virtual Museum!" / width="344" height="25"></td>
    <td class="topbannersides"><img src="/images/blhotelflorence.JPG" alt="The Hotel Florence" / width="150" height="86"></td>
  </tr>
  <tr id="topBannerRow2">
    <td class="bottombannersides">Pullman Virtual Museum</td>
    <td class="bottombannermiddle">PULLMAN HOUSE HISTORY PROJECT</td>
    <td class="bottombannersides">$year Census Information for $nameOfPerson</td>
  </tr>
</table>

<table>
  <tr>
    <td class="questionCell">Name:</td>
    <td class="answerCell"> $nameOfPerson</td>
  </tr>
  <tr>
    <td class="questionCell">Address:</td>
    <td class="answerCell"> $address $street</td>
  </tr>
  <tr>
    <td class="questionCell">Relation to<br>
    Head of Family:</td>
    <td class="answerCell"> $relation</td>
  </tr>
  <tr>
    <td class="questionCell">Sex:</td>
    <td class="answerCell"> $sex</td>
  </tr>
  <tr>
    <td class="questionCell">Race:</td>
    <td class="answerCell"> $race</td>
  </tr>
  <tr>
    <td class="questionCell">Date of Birth:</td>
    <td class="answerCell"> $dob</td>
  </tr>
  <tr>
    <td class="questionCell">Age:</td>
    <td class="answerCell"> $age</td>
  </tr>
  <tr>
    <td class="questionCell">Marital Status:</td>
    <td class="answerCell"> $maritalStatus</td>
  </tr>
  <tr>
    <td class="questionCell">No. of Years<br>
    Married:</td>
    <td class="answerCell"> $yearsMarried</td>
  </tr>
  <tr>
    <td class="questionCell">Mother of How<br>
    Many Children:</td>
    <td class="answerCell"> $motherOf</td>
  </tr>
  <tr>
    <td class="questionCell">No. of These<br>
    Still Living:</td>
    <td class="answerCell"> $childrenLiving</td>
  </tr>
  <tr>
    <td class="questionCell">Place of Birth:</td>
    <td class="answerCell"> $placeOfBirth</td>
  </tr>
  <tr>
    <td class="questionCell">Father's Place<br>
    of Birth:</td>
    <td class="answerCell"> $placeOfBirthFather</td>
  </tr>
  <tr>
    <td class="questionCell">Mother's Place<br>
    of Birth:</td>
    <td class="answerCell"> $placeOfBirthMother</td>
  </tr>
  <tr>
    <td class="questionCell">Year Immig.<br>
    To U.S.</td>
    <td class="answerCell"> $immigrated</td>
  </tr>
  <tr>
    <td class="questionCell">Nat. or Alien?</td>
    <td class="answerCell"> $naturalized</td>
  </tr>
  <tr>
    <td class="questionCell">No. of Years<br>
    in U.S.</td>
    <td class="answerCell"> $yearsInUS</td>
  </tr>
  <tr>
    <td class="questionCell">Occupation:</td>
    <td class="answerCell"> $occupation</td>
  </tr>
  <tr>
    <td class="questionCell">No. of Months<br>
    Unemployed:</td>
    <td class="answerCell">
    $monthsUnemployed</td>
  </tr>
  <tr>
    <td class="questionCell">Read?</td>
    <td class="answerCell"> $read</td>
  </tr>
  <tr>
    <td class="questionCell">Write?</td>
    <td class="answerCell"> $write</td>
  </tr>
  <tr>
    <td class="questionCell">Speaks English?</td>
    <td class="answerCell"> $english</td>
  </tr>
  <tr>
    <td class="questionCell">No. of Months<br>
    In School:</td>
    <td class="answerCell"> $monthsAtSchool</td>
  </tr>
  <tr>
    <td class="questionCell">Owned or Rented?</td>
    <td class="answerCell"> $ownOrRent</td>
  </tr>
  <tr>
    <td class="questionCell">Census Page Number</td>
    <td class="answerCell"> $pageNumber</td>
  </tr>
  <tr>
    <td class="questionCell">Census Line Number</td>
    <td class="answerCell"> $lineNumber</td>
  </tr>
  <tr>
    <td class="questionCell">Census Reel Number</td>
    <td class="answerCell"> $reelNumber</td>
  </tr>
   <tr>
    <td class="questionCell">Notes</td>
    <td class="answerCell"> $notes</td>
  </tr>
</table>
