XPath issue

G

Guest

I have an issue where I want to put an image right before the text for each
record below in a GridView. The problem is, the XPath is rss/channel/item".
So since I have the picture in my XML file under rss/channel/image/podcast
then how can I tell it to use rss/channel/image/podcast for the picture but
still use just rss/channel/item for the rest?

I've tried to change the XPath in the XMLDataSource to "rss/channel" then
set the paths in the Columns to item/description, item/title, and
/image/podcast but the GridView stops at the first record if I do this.

<asp:GridView
ID="GridView_Podcasts"
runat="server"
AllowPaging="true"
PageSize="5"
AllowSorting="true"
AutoGenerateColumns = "False"
DataSourceID="PodcastsXML"
BackColor="#FFFCC5"
BorderColor="Tan"
BorderWidth="1px"
CellPadding="2"
ForeColor="#FFFFFF"
GridLines="None">
<Columns>
<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:Image ID="Image1"
ImageUrl='<%#XPath("image/podcast")%>' runat="server" />
<asp:HyperLink ID="HyperLink1" runat="server"
Target="_blank" NavigateUrl='<%#XPath("title") %>' >
<%#XPath("title")%></asp:HyperLink>
<br /><br />
<asp:Label ID="Label1" runat="server"
Text=<%#XPath("description")%>></asp:Label>
<br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#000000" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#EFBA67" Font-Bold="True" />
<AlternatingRowStyle BackColor="#F8F8F7" />

</asp:GridView>
<asp:XmlDataSource ID="PodcastsXML" runat="server"
DataFile="~/interact/podcasts/rss/podcast.xml"
XPath="rss/channel/item"></asp:XmlDataSource>

Here's my XML:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>Ken Smith<title>
<link>http://www.sss.com</link>
<language>en-us</language>
<itunes:subtitle>Rroundtable for a lively discussion of the week's
news.</itunes:subtitle>
<itunes:author>sss.com</itunes:author>
<description> listeners turn to the Editors Roundtable for...
</description>
<image>
<url>http://localhost/images/header/sss_logo.jpg</url>
<title>Roundtable</title>
<link>http://www.sss.com</link>
</image>
<itunes:blush:wner>
<itunes:name>sss.com</itunes:name>
<itunes:email>[email protected]</itunes:email>
</itunes:blush:wner>
<itunes:image href="http://www.sss.com/images/header/sss_logo.jpg"
/>
<itunes:category text="sdfdfsd" />
<item>
<title>Recent trip to Chiapas</title>
<link>http://localhost/interact/podcasts/mp3s</link>
<description>Retrip to Chiapas, Mexico. This award-winning
author, and Mexican...</description>
<enclosure
url="http://localhost/interact/podcasts/mp3s/ss_Final.mp3" type="audio/mp3" />
<pubDate>Wed, 16 Aug 2006 13:00:00 GMT</pubDate>
<itunes:author>sss</itunes:author>
<itunes:duration>12:33</itunes:duration>
</item>
<item>
<title>Adam Smith</title>
<link>http://localhost/interact/podcasts/mp3s</link>
<description>Ken from ssscom discusses....</description>
<enclosure
url="http://localhost/interact/podcasts/mp3s/Seger2FINAL.mp3"
type="audio/mp3" />
<pubDate>Wed, 09 Aug 2006 13:00:00 GMT</pubDate>
<itunes:author>Ken Smoth</itunes:author>
<itunes:duration>8:27</itunes:duration>
</item>
 
T

Tasos Vogiatzoglou

The xml document has a default namespace. You will have to enable
somehow the namespace resolution in the grid (dunno if it's feasible)
or change the xpath to something like //[name()='rss']

Check for a previous post about Enterprise Block configuration files.


Regards,
Tasos
 
G

Guest

I resolved it:

<asp:Image ID="Image1"
ImageUrl='<%#XPath("../image/podcast")%>' runat="server" />


--
dba123


Tasos Vogiatzoglou said:
The xml document has a default namespace. You will have to enable
somehow the namespace resolution in the grid (dunno if it's feasible)
or change the xpath to something like //[name()='rss']

Check for a previous post about Enterprise Block configuration files.


Regards,
Tasos


I have an issue where I want to put an image right before the text for each
record below in a GridView. The problem is, the XPath is rss/channel/item".
So since I have the picture in my XML file under rss/channel/image/podcast
then how can I tell it to use rss/channel/image/podcast for the picture but
still use just rss/channel/item for the rest?

I've tried to change the XPath in the XMLDataSource to "rss/channel" then
set the paths in the Columns to item/description, item/title, and
/image/podcast but the GridView stops at the first record if I do this.

<asp:GridView
ID="GridView_Podcasts"
runat="server"
AllowPaging="true"
PageSize="5"
AllowSorting="true"
AutoGenerateColumns = "False"
DataSourceID="PodcastsXML"
BackColor="#FFFCC5"
BorderColor="Tan"
BorderWidth="1px"
CellPadding="2"
ForeColor="#FFFFFF"
GridLines="None">
<Columns>
<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:Image ID="Image1"
ImageUrl='<%#XPath("image/podcast")%>' runat="server" />
<asp:HyperLink ID="HyperLink1" runat="server"
Target="_blank" NavigateUrl='<%#XPath("title") %>' >
<%#XPath("title")%></asp:HyperLink>
<br /><br />
<asp:Label ID="Label1" runat="server"
Text=<%#XPath("description")%>></asp:Label>
<br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#000000" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#EFBA67" Font-Bold="True" />
<AlternatingRowStyle BackColor="#F8F8F7" />

</asp:GridView>
<asp:XmlDataSource ID="PodcastsXML" runat="server"
DataFile="~/interact/podcasts/rss/podcast.xml"
XPath="rss/channel/item"></asp:XmlDataSource>

Here's my XML:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>Ken Smith<title>
<link>http://www.sss.com</link>
<language>en-us</language>
<itunes:subtitle>Rroundtable for a lively discussion of the week's
news.</itunes:subtitle>
<itunes:author>sss.com</itunes:author>
<description> listeners turn to the Editors Roundtable for...
</description>
<image>
<url>http://localhost/images/header/sss_logo.jpg</url>
<title>Roundtable</title>
<link>http://www.sss.com</link>
</image>
<itunes:blush:wner>
<itunes:name>sss.com</itunes:name>
<itunes:email>[email protected]</itunes:email>
</itunes:blush:wner>
<itunes:image href="http://www.sss.com/images/header/sss_logo.jpg"
/>
<itunes:category text="sdfdfsd" />
<item>
<title>Recent trip to Chiapas</title>
<link>http://localhost/interact/podcasts/mp3s</link>
<description>Retrip to Chiapas, Mexico. This award-winning
author, and Mexican...</description>
<enclosure
url="http://localhost/interact/podcasts/mp3s/ss_Final.mp3" type="audio/mp3" />
<pubDate>Wed, 16 Aug 2006 13:00:00 GMT</pubDate>
<itunes:author>sss</itunes:author>
<itunes:duration>12:33</itunes:duration>
</item>
<item>
<title>Adam Smith</title>
<link>http://localhost/interact/podcasts/mp3s</link>
<description>Ken from ssscom discusses....</description>
<enclosure
url="http://localhost/interact/podcasts/mp3s/Seger2FINAL.mp3"
type="audio/mp3" />
<pubDate>Wed, 09 Aug 2006 13:00:00 GMT</pubDate>
<itunes:author>Ken Smoth</itunes:author>
<itunes:duration>8:27</itunes:duration>
</item>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top