How to quickly locate the interested information in the XML database under a certain twig pattern is a popular research topic.To solve the problem that the TwigStack algorithm for handling the case with parent-child nodes would come out with massive intermediate results,an improved twig pattern query algorithm of cTwigStack was proposed,which was based on caching the non-leaf nodes and delaying the leaf nodes output.The experimental results on Treebank dataset indicate that the proposed algorithm can achieve the most accurate results of the queries that contain the ancestor-descendant relationships below branching nodes.Besides,compared with the present algorithm,it is also highly effective when processing parent-child relationships below branching nodes.