1. A method of efficiently extracting relationship information from an HTML web page or XML document that has tagged elements, including: receiving electronically a relationship template that includes at least one declarative specification and a scope pattern, wherein the declarative specification includes at least a subject and an object that together define a relationship, and declares a pair of pattern matching specifications to identify text associated with pairs of the subject and the object, and wherein the scope pattern defines how closely the subject and the object are found together in a hierarchically structured document that uses tags that contain elements, wherein the scope pattern is expressed in terms of the tags that contain the elements; and applying the pattern matching specifications and the scope pattern in the relationship template to select and output one or more one-to-one pairs of the subject and the object found in a web page or XML document.