xpath,我必须做一个复杂的查询

时间:2014-11-14 18:21:31

标签: xpath

我正在学习xpath,我在查询时遇到了一些问题

这是我的dtd:

<! DOCTYPE database[
<! ELEMENT database(Customer*, Stock*, Zone*, Machine*, Seller*)>
<! ELEMENT Customer(social_id)>
<! ELEMENT Machine(name_machine)>
<! ELEMENT Seller(name_seller, cell-phone, email)>
<! ELEMENT Stock(howmany)>
<! ELEMENT ZOne(name_zone)>

<! ATTLIST Customer 
        id_customer ID #REQUIRED,
        id_zone IDREF #REQUIRED,
        id_seller IDREF #REQUIRED>

<! ATTLIST Machine id_machine ID #REQUIRED>

<! ATTLIST Seller   id_seller ID #REQUIRED>

<! ATTLIST Stock
        id_customer IDREF #REQUIRED,
        id_machine IDREF #REQUIRED,
        howmany CDATA #REQUIRED>

<! ATTLIST ZOne id_zone ID #REQUIRED>

<! ELEMENT name_machine (#PCDATA)>
<! ELEMENT name_seller (#PCDATA)>
<! ELEMENT name_zone (#PCDATA)>
<! ELEMENT email (#PCDATA)>
<! ELEMENT cell-phone (#PCDATA)>
<! ELEMENT social_id (#PCDATA)>]

我必须做的查询是: 1)从某个区域(特别是一个区域)获取客户的手机

感谢您的帮助,我也在学习,我很抱歉,如果写了一些错误的话

1 个答案:

答案 0 :(得分:1)

首先,我将创建一个遵循您拥有的DTD的XML文件,然后找到一个允许您试验XPath表达式的应用程序,以root //开头并获取所有节点,然后逐步运行到您需要的节点选择。