I am trying to write an XPath to pull the value 55.3469 from the tag below., but I am not sure where to start.
<tr class="uccRes">
<td width="47%" align="right" class="leftCol">100.00 <span class="uccResCde">ALL</span><!-- This is test data. -->
</td>
<td width="6%" valign="middle" align="center">=</td>
<td width="47%" align="left" class="rightCol">55.3469 <span class="uccResCde">AFN</span><!-- This is test data. -->
</td>
</tr>
First find the span with AFN text and class="uccResCde", then get the preceding-sibling:
//span[#class='uccResCde' and text()='AFN']/preceding-sibling::text()
Related
I am trying to create an html template that will be sent out to users.The issue with the rendered email is that the lists are not being rendered correctly, the formatting and nested list structure is being lost. This issue is on Outlook, whereas the formatting is correct in browser.
I followed the following thread (Trouble with ol and ul tags in email sent with Outlook) and tried to mimic a list using a table. It works fine for a single list. But since I have nested lists, I am unable to get the rendering setup correctly.
I have followed the following approaches:
<table cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center" valign="top">•</td>
<td align="left" valign="top"></td> List Item 1: </td>
</tr>
<tr>
<td></td> // Empty column, since sub-list should be at different level
<td>
<table cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center" valign="top">✔</td>
<td align="left" valign="top"></td> Nested List Item 1: </td>
</tr>
</table>
</td>
</tr>
</table>
I have also tried to nest the inner list by planing an extra empty column, instead of nested table.
<table cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center" valign="top">•</td>
<td align="left" valign="top"></td> List Item 1: </td>
</tr>
<tr>
<td width="20"></td> // empty column
<td width="20" align="center" valign="top">•</td>
<td align="left" valign="top"></td> Nested List Item 1: </td>
</tr>
</table>
But till now, I am unable to fix this. Any inputs would be appreciated.
The code has too many TDs being closed. Also, imo, the nested list should go inside the TD of the item it is nesting for, anyone looking at the code in the future will have a better understanding of how those things are linked if the nested list is inside the TD for the first item.
Here's a JSfiddle: https://jsfiddle.net/jabafpts/
And finally, code:
<table cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center" valign="top">•</td>
<td align="left" valign="top"> List Item 1
<table cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center" valign="top">✔</td>
<td align="left" valign="top">Nested List Item 1 </td>
</tr>
<tr>
<td width="20" align="center" valign="top">✔</td>
<td align="left" valign="top">Nested List Item 2 </td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="20" align="center" valign="top">•</td>
<td align="left" valign="top"> List Item 2</td>
</tr>
</table>
In my HTML text I want to ignore two (2) </tr>'s and capture text from the start to the third </tr>, my pattern is
string regularExpressionPattern = #"\<tr class=(.*?)\</tr>";
And here is the input text.
<tr class="oddrow">
<td>5Dimes.eu</td>
<td style="text-align:center;">
<table cellspacing="1" cellpadding="3" class="tablehead">
<tr>
<td width="50%" style="text-align:right;">SF: -3<br/>STL: +3</td>
<td style="text-align:left;">-111<br/>+101</td>
</tr>
</table>
</td>
<td style="text-align:center;">
<table cellspacing="1" cellpadding="3" class="tablehead">
<tr>
<td width="50%">41.5 O/U</td>
<td width="50%">o: -106<br/>u: -104</td>
</tr>
</table>
</td>
<td style="text-align:center;">SF: -160<br/>STL: 150</td>
</tr>
As you can see, there are three (3) </tr> tags.
How can I adjust my pattern to use the third tag rather than the first one?
Thanks
Try using this regular expression :
<tr class=.*?(<tr>.*?</tr>.*?)*</tr>
Just use
#"\<tr class=((.*?)\</tr>){3}"
For this code, when I add the text in the third table row it ruins the layout of all adjacent cells. Please help.
<table width="720" bgcolor="white" height="650" align="center" cellpadding="10" border="1">
<tr valign="top">
<td colspan="8" height="70" align="center"><img src="yooo.gif" align="middle" /> </td> </tr>
<tr height="40">
<td colspan="2" align="center" width="175">Home</td>
<td colspan="2" align="center" width="175">Food</td>
<td colspan="2" align="center" width="175">Hobbies</td>
<td colspan="2" align="center" width="175">Martin's Blog</td> </tr>
<tr height="260">
<td class="info" colspan="4" valign="top"><h2>Welcome to Nenad's Blog!!!</h2><h6>Here on this blog we will be talking about
a bunch of random stuff that are so completely unrelated that will blow your mind.<h6></td>
<td class="info" colspan="4"> h </td> </tr>
<tr height="260">
<td class="info" colspan="4"> h </td>
<td class="info" colspan="4"> h </td> </tr>
Your table looks good from what I can make of what you posted.
You should, however, not be using tables for layout purposes. They are supposed to be used only for tabular data, you know..like a spreadsheet.
For styling your site, you should be using CSS.
http://jsfiddle.net/3rJv7/
Code Runs
You might have to define what "ruin" means. However my best guess is that all the colspans cause some browsers to calculate the optimum column widths poorly. I found that many browsers handle it better if your first row defines the widths, even if it's a dummy row with spacer images. I know, terrible semantically, but using tables for layouts tend to go that way.
I have a scoreboard on my website that gets scores from an XML file. It's very easy for others to update, except for highlighting the winner.
This is a sample game from the XML file:
<game>
<month>05</month><day>25</day><year>11</year>
<type>Football</type>
<homeName>Wildcats</homeName><homeScore>45</homeScore><homeWinner></homeWinner>
<awayName>Bruins</awayName><awayScore>55</awayScore><awayWinner>y</awayWinner>
</game>
As you can see, I want them to simply check the winner. However, when it loads in HTML, I want the y to be replaced with an arrow image.
It's a Spry scoreboard, so here's the relevant HTML:
<script type="text/javascript">
var dsScoreboard = new Spry.Data.XMLDataSet("scoreboard.xml", "scoreboard/game", {sortOnLoad: "date", sortOrderOnLoad: "descending"});
dsScoreboard.setColumnType("date", "date");
</script>
<div spry:region="dsScoreboard">
<table class="scoreboard" cellspacing="15" cellpadding="0" border="0">
<tr>
<td spry:repeat="dsScoreboard">
<table class="game" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="date month">{month}</td>
<td class="type" colspan="3">{type}</td>
</tr>
<tr>
<td class="date day">{day}</td>
<td class="winner">{awayWinner}</td>
<td class="name">{awayName}</td>
<td class="score">{awayScore}</td>
</tr>
<tr>
<td class="date year">{year}</td>
<td class="winner">{homeWinner}</td>
<td class="name">{homeName}</td>
<td class="score">{homeScore}</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
So the output HTML for the winner cell should be something like:
<td class="winner"><img src="arrow.png" /></td>
instead of:
<td class="winner">y</td>
Can this be easily done? Thank you.
What you want is a spry:choose. I have never used spry, but it's something vaguely like this:
<td class="winner">
<span spry:choose="spry:choose">
<img src="arrow.png" spry:when="'{homeWinner}' == 'y'" />
<span spry:default="spry:default"></span>
</span>
</td>
I have a simmple HTML table that I just cant seem to fix.
I am trying to display data like so:
<-Previous Next->
51 to 100 of 10151 records
Below is the html code. I have taken out the dynamic language part that adds 'Previous' depending on what page the user is on:
EDIT: After all the responses I've changed the code to following. but still alignment is the same. >_<
<table width="100%" border="0">
<tbody>
<tr align="center">
<td bgcolor="#ffffff" color="white" align="center" colspan="2">
<!--some form elements go here!-->
<!--I just replaced tags with some text for testing-->
<font face="Arial" size="2"><strong>Previous</strong></font>
Previous
</td>
<td bgcolor="#ffffff" color="white" align="center" colspan="2">
Next
</td>
</tr>
<tr align="center">
<td align="center"><font face="arial" size="2"><b>51 to 100 of 10151</b> </font>
</td>
</tr>
</tbody>
</table>
Expected output is above but what I am getting from the code is:
Previous Next Group
51 to 100 of 10151 Households
I have been doing trial and error for quite some time now so need some help!
Why do you need table cells for both the Previous and Next text? Why not just put them in the same <td>?
<table width="100%" border="0">
<tbody>
<tr align="center">
<td bgcolor="#ffffff" color="white" align="center" colspan="2">
Previous Next
</td>
</tr>
<tr align="center">
<td align="center"><font face="arial" size="2"><b>51 to 100 of 10151</b></font></td>
</tr>
</tbody>
</table>
Did I miss a requirement?
You need to escape the attributes:
Value="<<Previous"
should be
Value="<<Previous"
Add a colspan="2" to the td in the second row.
use html entities to show < and > characters on the screen. < is < and > is >
Something that will also help is to use an editor that has syntax highlighting and you can catch these mistakes more easily
For starters, after your first row (<tr>...</tr>), you fail to start another row. Also, you need to column span the cell in the next row to make it take up the space under both cells in the row above it, not just the first one:
<tr>
<td align="center" colspan="2"><font....>....</td>
</tr>
Also, you have other HTML issues (you need to escape out HTML entities such as < and > if you want them to appear in your text), so you might want to run that through an editor that understands HTML or otherwise validate it.
You're missing some tags and quotes, and escape characters as others have mentioned.
You can try using the htmlvalidator at w3c.
http://validator.w3.org/#validate-by-input
<table width="100%" border="0">
<tr align="center">
<td bgcolor="#ffffff" color="white" align="center">
<!--some form elements go here!-->
<font face="Arial" size="2"><strong>Previous</strong></font>
<Input id='previuesButton' Type="image" alt="Previous" src="/eiv/images/prev.gif" value="<<Previous" name=previuesButton ACCESSKEY="B">
</td>
<td bgcolor="#ffffff" color="white" align="center">
<font face="Arial" size="2"><strong>Next Group</strong></font>
<Input id='nextButton' alt="Next" Type="image" src="/eiv/images/next.gif" Value="Next>>" name=nextButton ACCESSKEY="B">
</td>
</tr>
<tr>
<td align="center" colspan="2"><font face="arial" size="2"><b>51 to 100 of 10151</b> </font></td>
</tr>
</table>
You were missing a starting and ending row tag as well as a colspan in the bottom column. Try the above to see if that works out for you. Also you need to swap the less than and greater than characters for their equivalents (as shown above).
Are you having a problem with greater than or less than signs?
Try this:
<table width="100%" border="0">
<tbody>
<tr align="center">
<td bgcolor="#ffffff" color="white" align="center">
<!--some form elements go here!-->
<font face="Arial" size="2"><strong><-Previous</strong></font>
<Input id='previuesButton' Type="image" alt="Previous" src="/eiv/images/prev.gif"
Value="<<Previous" name=previuesButton ACCESSKEY="B">
</td>
<td bgcolor="#ffffff" color="white" align="center">
<font face="Arial" size="2"><strong>Next Group-></strong></font>
<Input id='nextButton' alt="Next" Type="image" src="/eiv/images/next.gif" Value="
Next>> "name=nextButton ACCESSKEY="B">
</td>
</tr>
<td align="center"><font face="arial" size="2"><b>51 to 100 of 10151</b> </font>
</td>
</tbody>
That help?
Your code, with:
The missing tags for the second row added in.
The arrows converted to html entities.
The missing quotes added in.
Your spelling corrected.
Try running your html through the w3c validator next time. Hope it helps.
<table width="100%" border="0">
<tbody>
<tr align="center">
<td bgcolor="#ffffff" color="white" align="center">
<font face="Arial" size="2"><strong>Previous</strong></font>
<Input id='previousButton' Type="image" alt="Previous" src="/eiv/images/prev.gif"
Value="<<Previous" name="previousButton" ACCESSKEY="B">
</td>
<td bgcolor="#ffffff" color="white" align="center">
<font face="Arial" size="2"><strong>Next Group</strong></font>
<Input id='nextButton' alt="Next" Type="image" src="/eiv/images/next.gif" Value="
Next >>" name="nextButton" ACCESSKEY="B"></td>
</tr>
<tr>
<td align="center" colspan="2"><font face="arial" size="2"><b>51 to 100 of 10151</b></font>
</td>
</tr>
</tbody>
</table>