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
Solved

XPath question

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

790 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