$dbc = mysqli_connect($host, $username, $password, $database);
$data = mysqli_query($dbc, "SELECT * FROM users");
while ($row = mysqli_fetch_array($data)) {
$res .= "<HeadNode>
<information>
<lastName>".$row['name']."</lastName>
<firstName>".$row['lastname']."</firstName>
<birthDate>".$row['bday']."</birthDate>
<gender>".$row['gender']."</gender>
</information>
<documents>
<document>
<type>Passport</type>
<number>".$row['number']."</number>
<issueDate>".$row['date']."</issueDate>
</document>
</documents>
<contacts>
<contact>
<type>Mphone</type>
<phoneNumber>".$row['mphone']."</phoneNumber>
</contact>
<contact>
<type>Hphone</type>
<phoneNumber>".$row['hphone']."</phoneNumber>
<region>
<code>".$row['region']."</code>
</region>
<city>
<code>".$row['city']."</code>
</city>
</contact>
<contact>
<type>Work</type>
<region>
<code>".$row['region']."</code>
</region>
<city>
<code>".$row['city']."</code>
</city>
</contact>
</contacts>
</HeadNode>";
}
mysqli_close($dbc);
echo $res;