Q:

Subsequence Search

I need to parse some xml code. I need to extract some values withing pattern elements. I made an example of my trouble.
Here is some complicated xml list:
list = {p[1, c, a, p[1, 2], q, b, b, a, p[3, 4], q, b, c, d, a, p[5, 6], q, b, {}, p[7, 8]]};

I need to extract this:
{{1, 2}, {3, 4}, {5, 6}}

I tried to use this pattern:
In[494]:= Cases[list,  p[__, a, p[x_, y_], q, __] :> {x, y}, Infinity]
Out[494]= {{1, 2}}

It doesn't work as I hope. (
I tried some other variants with ReplaceList, SequencePosition, but seems like I can't use it properly.
Mathematica 11.0
TQ
For solution TQ to Jason B. & m_goldberg
First of all, I understand that I need to extract most inner list with desired patterns. And then SequenceCases works well. Solution with Partition also works good.
I've compicated the example to show working solutions:
In[614]:=list = {p[1, c, a, p[1, 2], q, b, b, a, p[3, 4], q, b, c, d, a, p[5, 6], q, b, {}, p[7, 8], e, a, p[2], q, e]};
         First@Cases[list, p[args : PatternSequence[___, a, _p, q, ___]]:>SequenceCases[{args}, {a, p[x_, y_], q} :> {x, y}], Infinity]
         Cases[Partition[List @@ list[[1]], 3, 1], {a, p[x_, y_], q} -> {x, y}]

Out[615]= {{1, 2}, {3, 4}, {5, 6}}
Out[616]= {{1, 2}, {3, 4}, {5, 6}}

A:

I don't know how extensible this is, but it works for your case,
Cases[list,
    p[args:PatternSequence[___, a, _p, q, ___]] :> SequenceCases[
        {args},
        {a, p[x_, y_], q} :> {x, y}
    ],
    Infinity
]
(* {{{1, 2}, {3, 4}, {5, 6}}} *)

