XML Xpath没有返回我想要的内容

时间:2014-06-30 20:02:39

标签: c# xml xpath

我有XML

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  xmlns:dcterms="http://purl.org/dc/terms/" 
  xmlns:oslc="http://open-services.net/ns/core#" 
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <oslc:ResponseInfo rdf:about="https://timo-pcvirtual:9443/qm/oslc/users">
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/dave" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/al" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/ccm_user" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/GUEST" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/qm_user" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/build" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/rebecca" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/rm_user" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/marco" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/sally" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/tammy" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/tanuj" /> 
      <dcterms:title>Users</dcterms:title> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/ursula" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/etl_user" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/bob" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/curtis" /> 
      <oslc:totalCount>22</oslc:totalCount> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/lpa_user" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/timo" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/ADMIN" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/deb" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/jts_user" /> 
      <rdfs:member rdf:resource="https://timo-pcvirtual:9443/jts/users/unassigned" /> 
   </oslc:ResponseInfo>
</rdf:RDF>

我使用C#和xpath,我想选择所有rdfs:成员值(用户)

XPathDocument doc = new XPathDocument(response.GetResponseStream());
XPathNavigator nav = doc.CreateNavigator();
XmlNamespaceManager manager = new XmlNamespaceManager(nav.NameTable);
manager.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
manager.AddNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
manager.AddNamespace("oslc", "http://open-services.net/ns/core#");
XPathNodeIterator iterator = nav.Select("/rdf:RDF/oslc:ResponseInfo/@rdf:resource", manager);

迭代器计数为0,因为它找不到匹配项。我不明白为什么。

0 个答案:

没有答案