?
Solved

XPath question

Posted on 2013-01-18
3
Medium Priority
?
501 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

801 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