On Apr 28, 10:43 am, "Patrick Aljord" <patc... / gmail.com> wrote:
> hey all,
> I have a foaf.xml that looks like that:
[snip]
> I'm trying to get the names of all my friends:
> "bill" and "bob"

require 'rexml/document'

doc = REXML::Document.new( DATA.read )
p doc.each_element( '//foaf:knows/foaf:Person/foaf:name/text()' ){}
#=> ["bob", "bill"]

__END__
<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/">
    <foaf:Person rdf:about="http://myself.videntity.org/">
        <foaf:name>myself</foaf:name>
        <foaf:page>
            <foaf:Document rdf:about="http://myself.videntity.org/" /
>
        </foaf:page>
        <foaf:nick>myself</foaf:nick>
        <foaf:mbox rdf:resource="mailto:mys... / gmail.com" />
        <foaf:mbox_sha1sum>67b60b91fd6d4f68e32deae93956d36bc7c93c70</
foaf:mbox_sha1sum>
        <foaf:knows>
            <foaf:Person rdf:about="http://bob.videntity.org/">
                <foaf:name>bob</foaf:name>
                <foaf:homepage rdf:resource="http://
bob.videntity.org/" />
            </foaf:Person>
        </foaf:knows>
        <foaf:knows>
            <foaf:Person rdf:about="http://bill.videntity.org/">
                <foaf:name>bill</foaf:name>
                <foaf:homepage rdf:resource="http://
bill.videntity.org/" />
            </foaf:Person>
        </foaf:knows>
    </foaf:Person>
</rdf:RDF>