473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 4199
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
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
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.