Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XPath question

Posted on 2013-01-18
3
Medium Priority
?
505 Views
Last Modified: 2013-02-05
Hello again EE, I have little questions for vb.net

First,
lets say I have this:

<div class="Main">
   <td class="Event">
      <a href="abc" title="hello"></a>
      <a href="ggg" title="hi"></a>
    </td>
</div>

with xpath.. how can i get href and title of all tag <a> that is preceded only by a TD with class names="Event" ?  in this example, i would only get the first <a> not the second one..



Question two:
lets say I wan to search for a string in a HTML source that is not in any tag.. its juste a text between tags like:   <td><a href="dddd"></a><br />200 items left</td>

is there a way to get it ?

thanks for the help.
0
Comment
Question by:PhilippeRenaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 38795477
1) Try:

Dim anchors As XmlNodeList = xdoc.SelectNodes("//td[@class='Event']/a[1]")

For Each anchor As XmlNode In anchors
    Dim href As String = anchor.Attributes("href").Value
    Dim title As String = anchor.Attributes("title").Value
Next

Open in new window


2) I assume you are talking about the "200 items left" bit. That is actually a part of the <td> tag. Nevertheless, you might be able to use:

For Each td As XmlNode In xdoc.SelectNodes("//td")
    Dim text As String = td.InnerText
Next

Open in new window

0
 
LVL 1

Author Closing Comment

by:PhilippeRenaud
ID: 38807341
thanks
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 38855963
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question