Solved

XPath question

Posted on 2013-01-18
3
500 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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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