473,513 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPath issue

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>
<descriptionlisteners 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:owner>
<itunes:name>sss.com</itunes:name>
<itunes:email>in**@csss.com</itunes:email>
</itunes:owner>
<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>
--
dba123
Aug 28 '06 #1
2 4204
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

dba123 wrote:
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>
<descriptionlisteners 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:owner>
<itunes:name>sss.com</itunes:name>
<itunes:email>in**@csss.com</itunes:email>
</itunes:owner>
<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>
--
dba123
Aug 28 '06 #2
I resolved it:

<asp:Image ID="Image1"
ImageUrl='<%#XPath("../image/podcast")%>' runat="server" />
--
dba123
"Tasos Vogiatzoglou" wrote:
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

dba123 wrote:
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>
<descriptionlisteners 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:owner>
<itunes:name>sss.com</itunes:name>
<itunes:email>in**@csss.com</itunes:email>
</itunes:owner>
<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>
--
dba123

Aug 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2516
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
7
5466
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned...
4
5465
by: Bnaya Eshet | last post by:
I do like XPath, I really do. But I'm working on the compact framework which XPath is not included. So I come to understanding that if XPath do not come to the mountain,
1
10917
by: Rob | last post by:
Hi, I am moving through an XML document using an XPath Navigator, and I'd like to be able to get the xpath expression for the location of the current node from the root node. Any ideas how to...
3
1524
by: Patrick | last post by:
Dear Ng, after I have loaded am XmlDataDocument file, I try to extract a single node via XmlElement myElem = (XmlElement)this.XmlDataDocument.SelectSingleNode("/Document/Headerdata/myElem");...
3
2475
by: bruce | last post by:
for guys with python/xpath expertise.. i'm playing with xpath.. and i'm trying to solve an issue... i have the following kind of situation where i'm trying to get certain data. i have a...
3
2189
by: werD | last post by:
Hello I have an xml document that im currently using a forward only .net repeater on and using some xpath queries to display the data The xml is quite simple <?xml version="1.0"...
6
7276
by: J.Marsch | last post by:
I must be completely losing my mind. I have some code that writes to config files. It works great with app.config files, but fails miserably with web.config files. For the life of me, I cannot...
1
2209
by: bruce | last post by:
Hi. Got a test web page, that basically has two "<html" tags in it. Examining the page via Firefox/Dom Inspector, I can create a test xpath query "/html/body/form" which gets the target form for...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.