How to extract data from XML documents is an important issue for XML research and development. However, how to view XML documents determines how they can be queried. In this paper, we first describe a natural way to view XML documents as in complex object data models so that we can easily comprehend XML data from database point of view. We then illustrate how to use logical variables to extract data from XML documents. We also describe a rule-based declarative query language for XML. We demonstrate that our rule-based language provides a uniform framework that is advantageous over other XML query languages including XQuery in the following ways. First, it provides a natural way for separating querying and result constructing using the body and the head respectively. Second, several rules can be used for the same query so that complex queries can be expressed in a simple and natural way. Also, its use of logical variables and rules makes many functions and operators in XQuery and XPat...