By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,114 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,114 IT Pros & Developers. It's quick & easy.

Read RDF ?

P: n/a
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

Can somebody tell me what I do wrong?
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
If that's the code you're using you need to associate the reader with
the doc :-) i.e. using "xmlDoc.Load(reader)"

// pt

Nov 12 '05 #2

P: n/a
Vishal wrote:
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

Can somebody tell me what I do wrong?


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

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3

P: n/a
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

-----Original Message-----
Vishal wrote:
> 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

Can somebody tell me what I do wrong?


Where is the Load() call? And //xmlns:rdf/rdf is weird.

Most likely youmeant //rdf:rdf

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
.

Nov 12 '05 #4

P: n/a
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
-----Original Message-----
Oleg,

I forgot Load in this post, but I had it in my code. Therdf: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

-----Original Message-----
Vishal wrote:
> 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

Can somebody tell me what I do wrong?


Where is the Load() call? And //xmlns:rdf/rdf is weird.

Most likely you
meant //rdf:rdf

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
.

.

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.