This paper presents a framework for automatically generating structural XML documents. The user provides a target DTD and an example of an XML document, called a Generate-XML-By-Example Document, or a GxBE document, for short. GxBE docu-ments use a natural declarative syntax, which includes XPath ex-pressions and the function count. Using GxBE documents, users can express important global and local characteristics for the de-sired target documents, and can require satisfaction of XPath ex-pressions from a given workload. This paper explores the problem of efficiently generating a document that satisfies a given DTD and GxBE document.