1. A method for efficient Xpath matching of an Extensible Markup Language (XML) or JavaScript Object Notation (JSON) document, the method comprising: (a) identifying, by a device, an Xpath expression for processing values in a document comprising Extensible Markup Language (XML) or JavaScript Object Notation (JSON) content, the document represented by a stack of nodes; (b) traversing, by the device, the stack of nodes from top to bottom to match each step of a path expression of the Xpath expression to a type and name of one or more nodes in the stack of nodes; (c) storing, by the device, a flag with each node in the stack of nodes that matches a step of the path expression; (d) responsive to encountering a leaf node, tracing, by the device, bottom to top from the leaf node to one or more flagged nodes in the stack of nodes, and comparing each of the one or more flagged nodes against a corresponding step of the path expression; and (e) determining, by the device, whether the path expression is matched responsive to the tracing of the flagged nodes.