TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As editor of a journal I need to translate the bibliography, in a bbl file, into part of an xml file (for potential submission to cross-ref). It seems best done on the fly by pdfLaTeX so I can also record in the xml the main metadata (authors, title, pages, volume, etc). Currently I use a scheme for bbl files where the \bibitem does not involve brackets, e.g. \bibitem{Smith99} ... The problem is that as soon as the bbl file uses brackets (as in natbib) then my scheme fails catastrophically on \bibitem[blah]{Smith99} ... Question: how can I get pdfLaTeX to parse a bbl file, with such \bibitem[]{}, into an xml file while pdflatex is typesetting to pdf?

Currently I do the following (hacked from somewhere in latex and executed \AtBeginDocument):

    ^^J<citation key="#1"><unstructured_citation>}
  \immediate\read\jrnlin to\jrnltempa
\typeout{**** Starting to write the bibliography to the xml.}
    ^^J<citation key="nil"><unstructured_citation>}
\immediate\read\jrnlin to\jrnltempa  
\immediate\read\jrnlin to\jrnltempa
share|improve this question
Try using xparse, \usepackage{xparse}\DeclareExpandableDocumentCommand{\bibitem}{o{}m}{</unstruct‌​ured_citation></citation>^^J<citation key="#2" opt-arg="#1"><unstructured_citation>}. – Bruno Le Floch May 15 '13 at 11:59
Does this have to be done with the .bbl file? I've seen .bst files that deliberately add an XML section to the .bbl from BibTeX, which is easier as the data contains no formatting. – Joseph Wright Aug 16 '13 at 10:23
@JosephWright There was never feedback. Would you mind adding the bst-solution and/or a biblatex/biber solution if existing? In case we don't have a similar question on site, i think this is worth answering in some way. – Johannes_B Mar 29 '15 at 10:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.