We help IT Professionals succeed at work.
Get Started

XML/XPath Question

Besikci
Besikci asked
on
709 Views
Last Modified: 2013-11-11
Hi experts,

I have a read only XML file (converted from HTML) as follows:

<root>
  	<div class="league">
		  <h1>Premiership</h1>
	</div>
	<table class="matches">
		<tr class="match">
			<td>Man. Utd-Chelsea</td>
		</tr>
		<tr class="match">
			<td>Arsenal-Liverpool</td>
		</tr>
		<tr class="match">
			<td>Tottenham-Man.City</td>
		</tr>
	</table>
	<div class="league">
		  <h1>World Cup 2010</h1>
	</div>
	<table class="matches">
		<tr class="match">
			<td>England-USA</td>
		</tr>
	</table>
	<div class="league">
		  <h1>Swedish Superettan</h1>
	</div>
	<table class="matches">
		<tr class="match">
			<td>IFK Norrkoping-Orgryte IS</td>
		</tr>
	</table>
...
</root>

Open in new window


I'm trying to add leauges and matches together to a datagrid in VB.Net. I managed to add leagues only or matches only to the datagrid. (by iterating through div or table nodes). What I want is as follows:

Premiership                   Man. Utd-Chelsea
Premiership                   Arsenal-Liverpool
Premiership                   Tottenham-Man.City
World Cup 2010            England-USA
Swedish Superettan     IFK Norrkoping-Orgryte IS

I can get the matches if I iterate through using  /root/table[@class='matches'] or leauges /root/div[@class='leauge'].

How do I get them together?

Many thanks in advance.
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE