def build_article_from_xml(article_xml_filename, detail="brief",
                           build_parts=None, remove_tags=None):
    """
    Parse JATS XML with elifetools parser, and populate an
    eLifePOA article object
    Basic data crossref needs: article_id, doi, title, contributors with names set
    detail="brief" is normally enough,
    detail="full" will populate all the contributor affiliations that are linked by xref tags
    """
    build_part = lambda part: build_part_check(part, build_parts)

    error_count = 0

    soup = parser.parse_document(article_xml_filename)

    # Get DOI
    doi = parser.doi(soup)

    # Create the article object
    article = ea.Article(doi, title=None)

    # article version from the filename if possible
    utils.set_attr_if_value(article, 'version',
                            utils.version_from_xml_filename(article_xml_filename))

    # journal title
    if build_part('basic'):
        article.journal_title = parser.journal_title(soup)

    # issn
    if build_part('basic'):
        article.journal_issn = parser.journal_issn(soup, "electronic")
        if article.journal_issn is None:
            article.journal_issn = parser.journal_issn(soup)

    # Related articles
    if build_part('related_articles'):
        article.related_articles = build_related_articles(parser.related_article(soup))

    # Get publisher_id pii
    if build_part('basic'):
        article.pii = parser.publisher_id(soup)

    # set object manuscript value
    if build_part('basic'):
        manuscript = parser.publisher_id(soup)
        if not manuscript and doi:
            # try to get it from the DOI
            manuscript = doi.split('.')[-1]
        article.manuscript = manuscript

    # Set the articleType
    if build_part('basic'):
        article_type = parser.article_type(soup)
        if article_type:
            article.article_type = article_type

    # title
    if build_part('basic'):
        article.title = parser.full_title(soup)
    #print article.title

    # publisher_name
    if build_part('basic'):
        article.publisher_name = parser.publisher(soup)

    # abstract
    if build_part('abstract'):
        article.abstract = clean_abstract(parser.full_abstract(soup), remove_tags)

    # digest
    if build_part('abstract'):
        article.digest = clean_abstract(parser.full_digest(soup), remove_tags)

    # elocation-id
    if build_part('basic'):
        article.elocation_id = parser.elocation_id(soup)

    # issue
    if build_part('basic'):
        article.issue = parser.issue(soup)

    # self-uri
    if build_part('basic'):
        article.self_uri_list = build_self_uri_list(parser.self_uri(soup))

    # contributors
    if build_part('contributors'):
        # get the competing interests if available
        competing_interests = parser.competing_interests(soup, None)
        all_contributors = parser.contributors(soup, detail)
        author_contributors = [con for con in all_contributors
                               if con.get('type') in ['author', 'on-behalf-of']]
        contrib_type = "author"
        contributors = build_contributors(author_contributors, contrib_type, competing_interests)

        contrib_type = "author non-byline"
        authors = parser.authors_non_byline(soup, detail)
        contributors_non_byline = build_contributors(authors, contrib_type, competing_interests)
        article.contributors = contributors + contributors_non_byline

    # license href
    if build_part('license'):
        license_object = ea.License()
        license_object.href = parser.license_url(soup)
        license_object.copyright_statement = parser.copyright_statement(soup)
        article.license = license_object

    # article_category
    if build_part('categories'):
        article.article_categories = parser.category(soup)

    # keywords
    if build_part('keywords'):
        article.author_keywords = parser.keywords(soup)

    # research organisms
    if build_part('research_organisms'):
        article.research_organisms = parser.research_organism(soup)

    # funding awards
    if build_part('funding'):
        article.funding_awards = build_funding(parser.full_award_groups(soup))

    # datasets
    if build_part('datasets'):
        datasets_json = parser.datasets_json(soup)
        article.datasets = build_datasets(datasets_json)
        article.data_availability = build_data_availability(datasets_json)

    # references or citations
    if build_part('references'):
        article.ref_list = build_ref_list(parser.refs(soup))

    # components with component DOI
    if build_part('components'):
        article.component_list = build_components(parser.components(soup))

    # History dates
    if build_part('history'):
        date_types = ["received", "accepted"]
        for date_type in date_types:
            history_date = parser.history_date(soup, date_type)
            if history_date:
                date_instance = ea.ArticleDate(date_type, history_date)
                article.add_date(date_instance)

    # Pub date
    if build_part('pub_dates'):
        build_pub_dates(article, parser.pub_dates(soup))

    # Set the volume if present
    if build_part('volume'):
        volume = parser.volume(soup)
        if volume:
            article.volume = volume

    if build_part('is_poa'):
        article.is_poa = parser.is_poa(soup)

    return article, error_count