The core idea of XPath design can be quickly introduced by xpath to locate the desired node. The main purpose is to describe the location of a node relative to another node. All qualified nodes can be obtained and become [location paths]. Xapth is mainly used to query information in XML documents. You can use path expressions to parse XML files and read the data in XML files. The following is a case study. The XML file is as follows (simplexml. xml): [php] <? Xml version = "1.0" encoding = "UTF-8"?> <Books> <book house = "qinghuachubanshe"> <code> sb001 </code> <price> 200 </price> <author> xiaoming </author> <title> tianlongbabu </title> </book> <book house = "beidachubanshe"> <code> sb002 </code> <price> 400 </price> <author> daming </author> <title> xiaoaojianghu </title> </book> </books> PHP code is as follows: [php] <? Php // 1 create a DOMDocument object $ dom = new DOMDocument ("1.0", "UTF-8"); // 2 load the Xml file $ dom-> load ("simplexml. xml "); // 3 convert to the DomXPath object $ xpath = new DOMXPath ($ dom ); // 4 search for work $ node_list = $ xpath-> query ("/books/book/title"); echo "Total ". $ node_list-> length. "<br/>"; for ($ I = 0; $ I <$ node_list-> length; $ I ++) {$ node = $ node_list-> item ($ I); // var_dump ($ node_list);/* foreach ($ node as $ key => $ val) {echo