all groups > dotnet xml > november 2004 >
You're in the

dotnet xml

group:

Read RDF ?


Read RDF ? Vishal
11/26/2004 2:30:22 PM
dotnet xml: Hello,

I can easily read an RSS sheet, but I am not able able
to read a RDF sheet. Each time I try to read it returns me
0 nodes. Here is how I try it.

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs)
ReadRDF("http://www.xsltblog.com/index.rdf")
End Sub

Private function ReadRDF(byval strRDF as string)
Dim reader as new XmlTextReader(strRDF)
Dim xmlDoc as new XmlDocument

Dim nsmRequest as New XmlNamespaceManager
(xmlDoc.NameTable)
nsmRequest.AddNamespace
("xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-
ns#")
Dim nodes as XmlNodeList = xmlDoc.SelectNodes
("//xmlns:rdf/rdf", nsmRequest)
response.write(nodes.Count.ToString())
end function

Re: Read RDF ? Peter Theill
11/27/2004 8:20:15 AM
If that's the code you're using you need to associate the reader with
the doc :-) i.e. using "xmlDoc.Load(reader)"

// pt
Re: Read RDF ? Oleg Tkachenko [MVP]
11/28/2004 2:01:56 PM
[quoted text, click to view]

Where is the Load() call? And //xmlns:rdf/rdf is weird. Most likely you
meant //rdf:rdf

--
Oleg Tkachenko [XML MVP]
Re: Read RDF ? Vishal
12/2/2004 5:23:32 PM
Oleg,

I forgot Load in this post, but I had it in my code. The
rdf:rdf you suggested doesnt work either. I get the error:

Prefix 'rdf' is not defined.

My code again:

Private function ReadRDF(byval strRDF as string)
Dim reader as new XmlTextReader(strRDF)
Dim xmlDoc as new XmlDocument
xmlDoc.Load(strRDF)

Dim nsmRequest as New XmlNamespaceManager
(xmlDoc.NameTable)
nsmRequest.AddNamespace
("rdf:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
Dim nodes as XmlNodeList = xmlDoc.SelectNodes
("//rdf:rdf", nsmRequest)

response.write(nodes.Count.ToString())
end function

Thanks


[quoted text, click to view]
Re: Read RDF ? Sonu Kapoor
12/2/2004 5:51:38 PM
Try this:

Dim nsmRequest as New XmlNamespaceManager(xmlDoc.NameTable)
nsmRequest.AddNamespace
("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
nsmRequest.AddNamespace
("rss", "http://purl.org/rss/1.0/")

Dim nodes as XmlNodeList = xmlDoc.SelectNodes
("/rdf:RDF//rss:item/rss:title", nsmRequest)


Sonu

[quoted text, click to view]
AddThis Social Bookmark Button