C#:Using XPath with DOM Tutorial

From Progzoo
Jump to: navigation, search
A portion of the file http://xmlzoo.net/casablanca.xml is as shown:
<table class="infobox vevent" cellspacing="2" style="width: 20em; text-align: left; font-size: 90%;">
  <tr>...</tr>
  <tr>...</tr>
  <tr class="description">...</tr>
  <tr>...</tr>
  <tr>...</tr>
  <tr>
    <th>Starring</th>
    <td>
      <a href="/wiki/Humphrey_Bogart" title="Humphrey Bogart">Humphrey Bogart</a>
      <br/>
      <a href="/wiki/Ingrid_Bergman" title="Ingrid Bergman">Ingrid Bergman</a>
      <br/>
      <a href="/wiki/Paul_Henreid" title="Paul Henreid">Paul Henreid</a>
    </td>
  </tr>

SelectNodes

You can use the SelectNodes method to apply an XPath expression.

Change the program so that it prints each of those "Starring" in casablanca.xml


[Font] [Default] [Show] [Resize] [History] [Profile]