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), 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, the stack of nodes comprising the name of the node and a flag indicating a matching step; (c) storing, by the device, the 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 through each of the flagged nodes in the stack of nodes, and comparing each of the flagged nodes against a corresponding step of the path expression; and (e) determining, by the device responsive to the tracing through the flagged nodes, whether the path expression is matched based on whether there are enough nodes in the stack of nodes to match a minimum number of steps remaining in the path expression and each step in the path expression is matched to a corresponding flagged node.