473,386 Members | 1,720 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,386 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 2644
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.