473,796 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="ht tp://www.w3.org/1999/xhtml">
<channel>
<copyright>Copy right 2007</copyright>
<description>Ne ws 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>Ne ws description 1</description>
<link>http://link1.com</link>
<pubDate>Weds , 11 Apr 2007 23:38:35 GMT</pubDate>
<category>Busin ess</category>
<category>UK</category>
<category>April </category>
</item>
<item>
<title>News title 2</title>
<description>Ne ws 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>Ne ws description 3</description>
<link>http://link3.com</link>
<pubDate>Fri, 23 Mar 2007 23:38:35 GMT</pubDate>
<category>Busin ess</category>
<category>UK</category>
<category>March </category>
</item>
</channel>

</rss>

Apr 17 '07 #1
1 2663
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_...@hotma il.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="ht tp://www.w3.org/1999/xhtml">
<channel>
<copyright>Copy right 2007</copyright>
<description>Ne ws 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>Ne ws description 1</description>
<link>http://link1.com</link>
<pubDate>Weds , 11 Apr 2007 23:38:35 GMT</pubDate>
<category>Busin ess</category>
<category>UK</category>
<category>April </category>
</item>
<item>
<title>News title 2</title>
<description>Ne ws 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>Ne ws description 3</description>
<link>http://link3.com</link>
<pubDate>Fri, 23 Mar 2007 23:38:35 GMT</pubDate>
<category>Busin ess</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
1824
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 are stored in a free-format XML document (in memory for the life of the session) and persisted to a database (as free text) on exit. I have taught my developers the basics of XPath, however I don't want to have to review XMLDOM code all over the...
0
1930
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
6936
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 enable three line Python programs to extract data with XPath expressions? I have this problem a lot with Python and XML. Even with Uche's excellent yearly roundups I have a hard time finding how to do fancy things with XML in Python. I think it's...
13
2515
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. <FOO>foo.top.level</FOO> <BOO><FOO>foo.second.level</FOO></BOO> <CHOO><BOO><FOO>foo.third.level</FOO></BOO></CHOO>
8
7584
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 help constructing the Where clause of a SQL statement that will mirror the expressions and functions contained in the predicate. Such a tool may require an XML to DB mapping or it would need to make assumptions about the structure of the...
3
4547
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 should result in a NodeSet". Of course, that (sort of) makes sense to me now (I suppose just an attribute couldn't be a nodeset, but how would I go
6
15511
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
5630
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
3250
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 Insert node values to narrow down XPath results
2
1793
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 this as I have received this XML and I didn't create it. All I want to is retrieve the PROJECTNAME from the following XML. I am typing this XML and XPATH into this site http://www.activsoftware.com/xml/xpath/ The XPATH that does not work is...
0
10457
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10231
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.