473,804 Members | 2,202 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 2665
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
1932
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
2517
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
15514
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
5631
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
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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,...
1
10354
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
9175
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
6867
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
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
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
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.