GedCom Parser

A simple GEDCOM parser that focuses on translating GEDCOM structure into a GedCom Library.

Tested with GEDCOM 5.5 exported from Ancestry.com.

What is GEDCOM?

GEDCOM (an acronym standing for Genealogical Data Communication) is an open de facto specification for exchanging genealogical data between different genealogy software. GEDCOM was developed by The Church of Jesus Christ of Latter-day Saints (LDS Church) as an aid to genealogical research.

More on Wikipedia.

About the structure

About structure A GEDCOM file consists of a header section, records, and a trailer section. Within these sections, records represent people (INDI record), families (FAM records), sources of information (SOUR records), and other miscellaneous records, including notes. Every line of a GEDCOM file begins with a level number where all top-level records (HEAD, TRLR, SUBN, and each INDI, FAM, OBJE, NOTE, REPO, SOUR, and SUBM) begin with a line with level 0, while other level numbers are positive integers.

Example

Example The following is a sample GEDCOM file contains families of the Lincolns. The first column indicates an indentation level.

The header (HEAD) includes the source program and version (Ancestry.com, 2010.3), the GEDCOM version (5.5), and the character encoding (UTF-8), as according to the GEDCOM 5.5 specification; valid choices are ANSEL, UNICODE or ASCII.

The individual records (INDI) define Sarah (ID @I1@), Sarah Evans (ID @I2@), Rebecca Flowers (ID @I3@ etc, etc.).

The family record (FAM) links the husband (HUSB), wife (WIFE), and child (CHIL) by their ID numbers.

Usage

Load a GEDCOM file into GedCom Parser

<script src='GedCom.js'></script>
<script type="text/javascript">
    var gedcom = new GedCom("./Sample.ged", function(instance){
        //Do something when GedCom Parser is ready
    });
    //or
    var gedcom = new GedCom("./Sample.ged", {
        start: function(filename, content){
            //Do something when GEDCOM file parsing is started
        },
        done: function(instance){
            //Do something when GedCom Parser is ready
        },
        error: function(error){
            //Do something when GEDCOM file parsing is not completed
        },
        progress: function(percent){
            //Do something while GEDCOM is parsing
        }
    });
</script>

Get a record

Get an individual
<script src='GedCom.js'></script>
<script type="text/javascript">
    var gedcom = new GedCom("./Sample.ged", function(instance){
        var indi = instance.getIndividuals().get('@I1@');
        //or
        var indi = instance.getIndividuals('@I1@');
    });
</script>
Get a family
<script src='GedCom.js'></script>
<script type="text/javascript">
    var gedcom = new GedCom("./Sample.ged", function(instance){
        var fam = instance.getFamilies().get('@F1@');
        //or
        var fam = instance.getFamilies('@F1@');
    });
</script>
Get relatives of an individual
<script src='GedCom.js'></script>
<script type="text/javascript">
    var gedcom = new GedCom("./Sample.ged", function(instance){
        var indi = instance.getFamilies().get('@I1@');

        if( indi != undefined )
        {
            var siblings = indi.getSiblings();
            var parents = indi.getParents();
            var children = indi.getChildren();
            //etc there are a lot of methods to get all types of relatives.        
        }
    });
</script>

Usage Online

There's also a live example to demonstrate how you'd use GedCom Parser.

Browser support

4.0 8.0 3.5 3.2 9.6

About Rights

Copyright (C) Dávid Imre - All Rights Reserved.

Unauthorized copying of this file, via any medium is strictly prohibited.

Proprietary and confidential.

Written by Dávid Imre envagyok@idavid.hu, October 2016.

Changelog

1.4.31

1.3.83

  • The GedCom Parser first release