我在jcabi
处理一些数据时发现了意外的行为。
数据(只是开始)
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcat="http://www.w3.org/ns/dcat#" xmlns:dct="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<dcat:Dataset rdf:about="http://about.html">
<owl:sameAs rdf:resource="urn:uuid:123456789810" />
<dct:description>SOME....</dct:description>
<dcat:keyword>SOME....</dcat:keyword>
<foaf:homepage rdf:resource="http://zzzzzzzzz" />
<rdfs:label>SOME....</rdfs:label>
<dct:identifier>SOME....</dct:identifier>
<dct:title>SOME....</dct:title>
<dcat:distribution>
<dcat:Distribution>
<dcat:accessURL rdf:resource="http://xxxxxxxxx" />
<dct:title>Data 1</dct:title>
</dcat:Distribution>
</dcat:distribution>
<dcat:distribution>
<dcat:Distribution>
<dcat:accessURL rdf:resource="http://yyyyyyyyy" />
<dct:title>Data 2</dct:title>
</dcat:Distribution>
</dcat:distribution>
<!-- ... -->
</dcat:Dataset>
</rdf:RDF>
我尝试获取列表dcat:distribution
编码:
XML xml = new XMLDocument(data);
List<XML> lista = xml.nodes("/rdf:RDF[1]/dcat:DataSet[1]/dcat:distribution");
我得到这个错误:
invalid XPath query '/rdf:RDF[1]/dcat:DataSet[1]/dcat:distribution' by com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl
我尝试:
/rdf:RDF/dcat:DataSet/dcat:distribution
//dcat:DataSet/dcat:distribution
//dcat:distribution
/rdf:RDF/dcat:DataSet
//dcat:DataSet
有任何想法吗?
亲切的问候