A soldier is a person who has enlisted with, or was drafted into, the armed forces of a sovereign country and has undergone training and received equipment to defend that country or its interests. Soldiers are a part of strictly hierarchical societies called armies. Within the army, groups of soldiers are usually divided into military units of some kind.
Infantry are soldiers who specialize in ground combat. Not all soldiers are infantry, and not all infantry are soldiers. Infantry that are not soldiers include members of the Royal Air Force Regiment of the United Kingdom (technically they are airmen not soldiers), and members of the United States Marine Corps, Royal Marines of the United Kingdom, or other marine forces (who are marines not soldiers; in fact many marines bristle at being called soldiers). Finally, many navies maintain naval infantry, who are sailors not soldiers.
A pre-modern soldier is also called a warrior. The word warrior implies one who is not part of a full-time army. Without strict heirarchial discipline constantly being imposed on them, warriors in pre-modern societies were often guided by societal warrior codes.