473,397 Members | 2,099 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,397 software developers and data experts.

XPath help

JHD
Hi,

I'm trying to use the XMLDataSource and DataList controls in Visual Web
Developer Express (VB.Net) to present the following rss file in a web
application. The problem lies in that I want to just select items (title,
description and link) that are in the 'april' category. Can anyone help me
with an XPath expression (or another way) of achieving this?

Thanks.
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<channel>
<copyright>Copyright 2007</copyright>
<description>News Alerts</description>
<link></link>
<title></title>
<language>en</language>
<lastBuildDate>Thu, 12 Apr 2007 20:32:25 GMT</lastBuildDate>
<item>
<title>News title 1</title>
<description>News description 1</description>
<link>http://link1.com</link>
<pubDate>Weds, 11 Apr 2007 23:38:35 GMT</pubDate>
<category>Business</category>
<category>UK</category>
<category>April</category>
</item>
<item>
<title>News title 2</title>
<description>News description 2</description>
<link>http://link2.com</link>
<pubDate>Weds, 11 Apr 2007 23:38:35 GMT</pubDate>
<category>Sport</category>
<category>US</category>
<category>April</category>
</item>
<item>
<title>News title 3</title>
<description>News description 3</description>
<link>http://link3.com</link>
<pubDate>Fri, 23 Mar 2007 23:38:35 GMT</pubDate>
<category>Business</category>
<category>UK</category>
<category>March</category>
</item>
</channel>

</rss>

Apr 17 '07 #1
1 1093
The following XPath expression returns the elements you need in a
nodeset result:

/rss/channel/item/pubDate[contains(.,"Apr")]/preceding-sibling::*

Cheers

Phil

http://pgfearo.googlepages.com/home
On Apr 17, 11:19 pm, "JHD" <jack_...@hotmail.comwrote:
Hi,

I'm trying to use the XMLDataSource and DataList controls in Visual Web
Developer Express (VB.Net) to present the following rss file in a web
application. The problem lies in that I want to just select items (title,
description and link) that are in the 'april' category. Can anyone help me
with an XPath expression (or another way) of achieving this?

Thanks.

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<channel>
<copyright>Copyright 2007</copyright>
<description>News Alerts</description>
<link></link>
<title></title>
<language>en</language>
<lastBuildDate>Thu, 12 Apr 2007 20:32:25 GMT</lastBuildDate>
<item>
<title>News title 1</title>
<description>News description 1</description>
<link>http://link1.com</link>
<pubDate>Weds, 11 Apr 2007 23:38:35 GMT</pubDate>
<category>Business</category>
<category>UK</category>
<category>April</category>
</item>
<item>
<title>News title 2</title>
<description>News description 2</description>
<link>http://link2.com</link>
<pubDate>Weds, 11 Apr 2007 23:38:35 GMT</pubDate>
<category>Sport</category>
<category>US</category>
<category>April</category>
</item>
<item>
<title>News title 3</title>
<description>News description 3</description>
<link>http://link3.com</link>
<pubDate>Fri, 23 Mar 2007 23:38:35 GMT</pubDate>
<category>Business</category>
<category>UK</category>
<category>March</category>
</item>
</channel>

</rss>

May 4 '07 #2

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

Similar topics

0
by: bdinmstig | last post by:
I am building various framework components for my team to use in development, and one of those components is a Facade for reading/writing user preferences. The idea is that preference settings...
0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
3
by: Nelson Minar | last post by:
Could someone help me get started using XPath or XQuery in Python? I'm overwhelmed by all the various options and am lacking guidance on what the simplest way to go is. What library do I need to...
13
by: tfsquare | last post by:
All, I am new to XSLT and having some problems understanding the syntax of XPath which selects nodes in the XML document. Consider this bit of XML, which contains three outer XML elements. ...
8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
6
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
2
by: Locusta | last post by:
Hello, I would like to use XPATH in a C program to retrieve values from XML documents. Did anyone tried this and can give me some advice? Cheers, Locusta
3
by: ziggyware | last post by:
Hi All, I have updated my XPath Generator software: XPath Studio .NET. ( http://www.ziggyware.com/downloads.php?cat_id=2 ) Easily select nodes from an xml file to generate XPath statements ...
2
by: Monty | last post by:
Despite reading posts in Google, I don't understand XPATH. Can someone help me write an XPATH. From Google I think my problem is that the default namespace does not have a prefix. I can't change...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
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...

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.