I am using the Xmldatasource Control and XPathNavigator (in code behind) to parse an XML file for output on a website. For the output I am using a Repeater doing something like this:
<asp:XmlDataSource ID="RssFeed" runat="server" DataFile="example.xml" XPath="/rss/channel/item[position()<10]"></asp:XmlDataSource>
<asp:Repeater ID="repeater1" runat="server" DataSourceID="RssFeed" OnItemDataBound="repeater1_ItemDataBound">
<p><%# XPath("title") %></p>
<p><%# XPath("description") %></p>
That works fine until the one of the XML tags has a prefix like <dc:creator>.
If I try <p><%# XPath("dc:creator") %></p>, then I get this error message:
Exception Details: System.Xml.XPath.XPathException: Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
How would I get at a tag with a prefix?
The problem with that is I was using the XMLDataSource control and apparently it doesn't support namespaces. Seemed like it was perfect way to parse XML when using .NET 2.0. Now I have to rethink it.
This topic is now archived. It is frozen and cannot be changed in any way.