Error reading XML File (API)

I am trying to read data from an xml file (API) using the repeater control in but I am getting the following error: XmlNodeList’ is a type and cannot be used as an expression. t

The error is pointing at this line from the code below:

XmlNodeList nodes = doc.SelectNodes("products/product")

Can anyone please help fix this error?

The code is shown below:

<Script runat="server">
sub Page_Load
if Not Page.IsPostBack then Dim doc  as XmlDocument = new XmlDocument()
doc.Load("this is the url link")
 XmlNodeList  nodes  = doc.SelectNodes("products/product")
rpMyRepeater.DataSource = nodes
end if
end sub

<asp:repeater id="rpMyRepeater" runat="server">
<%# ((System.Xml.XmlNode)Container.DataItem).Attributes["description"].Value %>
 <%# ((System.Xml.XmlNode)Container.DataItem).InnerXml %>


I think you have to use nodes.AsQueryable() so the DataSource can utilize it.

I tried that but unfortunately it still shows the same error

How about using XmlDataSource to load the XML into and then bind the XmlDataSource to the repeater?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.