Christos Asa
Christos Asa

Reputation: 155

Xpaths query problem

<?xml version='1.0'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
    <head>
        <variable name='r'/>
    </head>
    <results>
    <result>
        <binding name='r'>
            <uri>http://127.0.0.1/rdfs/CRM.rdfs#E1.CRM_Entity</uri>
        </binding>
    </result>
    </results>
 </sparql>

i have this xml and i trying to parse the values using xpath and exist db (in java). but the only one query which give me feedback is " //* ". I want to take the value of uri but i cant't. The //uri returns me null. I use eclipse tool about xpaths. It generate me the path but when i try that path in the same tools returns me again null. Any idea? thanks in advance...

Upvotes: 2

Views: 67

Answers (1)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56162

Your XML has default namespace: http://www.w3.org/2005/sparql-results#. So you need to define it in your XML/XPath engine, define prefix (e.g. pr) and use it in XPath: //pr:uri. Or you can use this XPath:
//*[local-name() = 'uri'].

Upvotes: 2

Related Questions