P
Patrick Aljord
hey all,
I have a foaf.xml that looks like that:
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xfn="http://gmpg.org/xfn/">
<foaferson rdf:about="http://myself.videntity.org/">
<foaf:name>myself</foaf:name>
<foafage>
<foafocument rdf:about="http://myself.videntity.org/" />
</foafage>
<foaf:nick>myself</foaf:nick>
<foaf:mbox rdf:resource="mailto:[email protected]" />
<foaf:mbox_sha1sum>67b60b91fd6d4f68e32deae93956d36bc7c93c70</foaf:mbox_sha1sum>
<foaf:knows>
<foaferson rdf:about="http://bob.videntity.org/">
<foaf:name>bob</foaf:name>
<foaf:homepage rdf:resource="http://bob.videntity.org/" />
</foaferson>
</foaf:knows>
<foaf:knows>
<foaferson rdf:about="http://bill.videntity.org/">
<foaf:name>bill</foaf:name>
<foaf:homepage rdf:resource="http://bill.videntity.org/" />
</foaferson>
</foaf:knows>
</foaferson>
</rdf:RDF>
I put all this into a string @f and then I create a doc:
doc=Document.new(@f.body)
@foaffriends=doc.root
I'm trying to get the names of all my friends:
"bill" and "bob"
If I do:
@foaffriends[1].elements['foaf:knows'][1].elements['foaf:name']
I get "bob" but I can't figure out how to get "bill".
I tried:
@foaffriends[1].elements['foaf:knows'][2].elements['foaf:name']
but it returned nil.
Any idea how to get all my friends name?
thanx in advance
Pat
I have a foaf.xml that looks like that:
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xfn="http://gmpg.org/xfn/">
<foaferson rdf:about="http://myself.videntity.org/">
<foaf:name>myself</foaf:name>
<foafage>
<foafocument rdf:about="http://myself.videntity.org/" />
</foafage>
<foaf:nick>myself</foaf:nick>
<foaf:mbox rdf:resource="mailto:[email protected]" />
<foaf:mbox_sha1sum>67b60b91fd6d4f68e32deae93956d36bc7c93c70</foaf:mbox_sha1sum>
<foaf:knows>
<foaferson rdf:about="http://bob.videntity.org/">
<foaf:name>bob</foaf:name>
<foaf:homepage rdf:resource="http://bob.videntity.org/" />
</foaferson>
</foaf:knows>
<foaf:knows>
<foaferson rdf:about="http://bill.videntity.org/">
<foaf:name>bill</foaf:name>
<foaf:homepage rdf:resource="http://bill.videntity.org/" />
</foaferson>
</foaf:knows>
</foaferson>
</rdf:RDF>
I put all this into a string @f and then I create a doc:
doc=Document.new(@f.body)
@foaffriends=doc.root
I'm trying to get the names of all my friends:
"bill" and "bob"
If I do:
@foaffriends[1].elements['foaf:knows'][1].elements['foaf:name']
I get "bob" but I can't figure out how to get "bill".
I tried:
@foaffriends[1].elements['foaf:knows'][2].elements['foaf:name']
but it returned nil.
Any idea how to get all my friends name?
thanx in advance
Pat