繁体   English   中英

w3c 文档 xpath 不返回节点集

[英]w3c Document xpath does not return nodeset

你好:) 我想要所有enumeration节点,但集合的长度返回 0。将来我需要enumeration.value属性列表,因此例如目前它将包含 WOW 的单元素列表。 但问题是我根本无法选择enumeration节点。

xml部分:

<xs:complexType name="Code.Something">
      <xs:complexContent>
         <xs:restriction base="xxx:Code">
            <xs:sequence>
               <xs:element name="code" form="unqualified">
                  <xs:simpleType>
                     <xs:restriction base="xs:token">
                        <xs:enumeration value="WOW">
                           <xs:annotation>
                              <xs:appinfo>
                                 <Test>ABC</Test>
                              </xs:appinfo>
                           </xs:annotation>
                        </xs:enumeration>

这有长度 1:

((NodeList) xPath.evaluate("//*[local-name()='complexType'][@name='Code.Something']",
        doc, XPathConstants.NODESET)).getLength(); 

这有长度 0 - 为什么?:

 ((NodeList) xPath.evaluate("//*[local-name()='complexType'][@name='Code.Something']/*[local-name()='enumeration']",
        doc, XPathConstants.NODESET)).getLength(); 

节点之间的单斜杠 ( node1/node2 ) 表示您想要 select node2 ,它是node1的直接子节点。 您需要在节点 ( node1//node2 ) 到 select node2之间使用双斜杠// ,它是node1的后代

//*[local-name()='complexType'][@name='Code.Something']//*[local-name()='enumeration']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM