[ create a new paste ] login | about

Link: http://codepad.org/ZdaJ1FGR    [ raw code | output | fork ]

PHP, pasted on Mar 15:
<?php
$xml = <<< XHTML
<table>
	<tbody>
		<tr class="heading_table_top">
			<th width="6%">SNo</th>
			<th width="9%">Stn Code</th>
			<th width="17%">Stn Name</th>
			<th width="9%">Route No.</th>
			<th width="9%">Arrival Time</th>
			<th width="9%">Dep. Time</th>
			<th width="15%">Halt Time (In Minutes)</th>
			<th width="9%">Distance</th>
			<th width="6%">Day</th>
			<th width="20%">Remark</th>
		</tr>
	</tbody>
</table>
XHTML;

$dom = new DOMDocument;
$dom->loadXml($xml);
$xp = new DOMXPath($dom);
$nodes = $xp->evaluate(
    '//table[descendant::th="Stn Code" and  descendant::th="Route No."]'
);
foreach ($nodes as $node) {
    echo $dom->saveXml($node);
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<table>
	<tbody>
		<tr class="heading_table_top">
			<th width="6%">SNo</th>
			<th width="9%">Stn Code</th>
			<th width="17%">Stn Name</th>
			<th width="9%">Route No.</th>
			<th width="9%">Arrival Time</th>
			<th width="9%">Dep. Time</th>
			<th width="15%">Halt Time (In Minutes)</th>
			<th width="9%">Distance</th>
			<th width="6%">Day</th>
			<th width="20%">Remark</th>
		</tr>
	</tbody>
</table>


Create a new paste based on this one


Comments: