473,888 Members | 1,551 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 2668
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
1830
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
1937
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
6938
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
2521
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
7592
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
4548
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
15519
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
5650
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
3256
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
1796
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
9800
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10778
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
10886
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
10439
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
9597
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5824
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
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4245
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.