Replace XML Value in HTML - html

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>

Related

Select Link after fetching label in front of it

I am writing a selenium java code and at a particular webpage i want to select a link from a group of links where each link has an emebeded text within a table. How can i select particular link at this situtation. for eg.
run title--text 1
run title--text 2
run title--text 3
how can select specific run link for a specific title text? the text is not a label rather it is just simple text on the webpage.
i am using the following code:
verify.text("text 1");
it will only verify the presence of text, it wont go towards the link as link of every execution is named RUN. so it will identify the corresponding run link? The HTML code for the above is:
<HTML>
<HEAD>
<TITLE>TEST</TITLE>
</HEAD>
<BODY>
<div align="center"><table class="module" width="630">
<tr>
<th class="banner" width="70">ACTION</th>
<th class="banner" width="560">REPORT TEMPLATE</th>
</tr>
<tr>
<td class="modulenav" width="70">
<table class="innermodule" width="100%">
<tr><td class="moduleNav"><a class="listingLink"
href="www.abc.com/">Run</a></td></tr>
<tr><td class="moduleNav"><a class="listingLink"
href="www.zxc.com">UnShare</a></td></tr>
</table>
</td>
<td>
<table class="innerModule" width="100%">
<tr>
<td class="label" width="70">Title</td>
<td width="490"><span class="listingHead">Incident Performance by Priority</span></td>
</tr>
<tr>
<td class="Label" width="70">Description</td>
<td class="listing"></td>
</tr>
<tr>
<td class="Label" width="70">Owner</td>
<td class="listing"> Software Engineer Tel: </td>
</tr>
<tr>
<td class="Label" width="70">Shared With</td>
<td class="listing">
Software Engineer Tel: <br>
</td>
</tr>
<tr>
<td class="label">Report Type</td>
<td class="listing">Performance by Priority</td>
</tr>
</table>
</td>
</tr>
<tr><td class="tableRuleNavy" colspan="2"></td></tr>
<tr>
<td class="modulenav" width="70">
<table class="innermodule" width="100%">
<tr><td class="moduleNav"><a class="listingLink"
href="www.abc.com">Run</a></td></tr>
<tr><td class="moduleNav"><a class="listingLink"
href="www.cxd.com">UnShare</a></td></tr>
</table>
</td>
<td>
<table class="innerModule" width="100%">
<tr>
<td class="label" width="70">Title</td>
<td width="490"><span class="listingHead">Incident Trend Analysis Report</span></td>
</tr>
<tr>
<td class="Label" width="70">Description</td>
<td class="listing"></td>
</tr>
<tr>
<td class="Label" width="70">Owner</td>
<td class="listing">Software Engineer Tel: </td>
</tr>
<tr>
<td class="Label" width="70">Shared With</td>
<td class="listing">
Software Engineer Tel: <br>
</td>
</tr>
<tr>
<td class="label">Report Type</td>
<td class="listing">Trend Analysis</td>
</tr>
</table>
</td>
</tr>
<tr><td class="tableRuleNavy" colspan="2"></td></tr>
<tr>
<td class="modulenav" width="70">
<table class="innermodule" width="100%">
<tr><td class="moduleNav"><a class="listingLink"
href="www.sdfds.com">Run</a></td></tr>
<tr><td class="moduleNav"><a class="listingLink"
href="www.asdg.com">UnShare</a></td></tr>
</table>
</DIV>
</td>
</BODY>
</HTML>
Get a list of web elements and iterate over them.
This is not tested
E.g.
List<WebElement> we = findElements(By.cssSelector("tr a"));
Iterator itor = we.iterator()
While(itor.hasNext()) {
WebElement we = itor.next();
if (we.getText().equals("your visible text")) {
we.click // click link
}
}

Need help writing an XpathQueryString

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()

HTML regex ignore tags

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}"

Table row on top of columns

The text I have on top in the table row is somehow affected by the second column below it..cant seem to have it take up the entire width of the table.
http://jsfiddle.net/PmWBw/2/
Sorry I know I am the only one still working in tables. HTML emails still exist.
<table width="800" class="bodyContent" style="border: 1px solid #b8b7b7;margin-bottom: 20px;">
<table>
<tr style="width: 800px;">TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT</tr>
</table>
<td valign="top" width="260" class="leftColumnContent">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_left.png" mc:label="image" mc:edit="tiwc300_image00" />
</td>
</tr>
</table>
</td>
<td valign="top" width="260" class="rightColumnContent">
<!-- // Begin Module: Top Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_right.png" mc:label="image" mc:edit="tiwc300_image01" />
</td>
</tr>
</table>
</td>
</table>
For starters, your first row consists of a td inside a tr that's inside ANOTHER td. If nothing else, that should probably be addressed.
Also, a bit unrelated to you original question, but it seems a bit redundant to have tables inside of your cells, when I'm not seeing any real benefit or function gained by the added code. You're styling your inner tables with the same things you can be applying to either the td or the image itself. At least in this particular application.
Just a thought.
UPDATED:
<table width="600" class="bodyContent" style="border: 1px solid #b8b7b7;margin-bottom: 20px;">
<tr>
<td colspan="2">
<table>
<tr style="width: 600px;">
<td>TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="260" class="leftColumnContent">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_left.png" mc:label="image" mc:edit="tiwc300_image00" />
</td>
</tr>
</table>
</td>
<td valign="top" width="260" class="rightColumnContent">
<!-- // Begin Module: Top Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_right.png" mc:label="image" mc:edit="tiwc300_image01" />
</td>
</tr>
</table>
</td>
</tr>
</table>
First of all, you can not have the code looking like this:<td><tr><td>asdf</td></tr></td>. It the <tr> needs to be wrapped by <table>.

wrap a single line of text in a dynamic div

I have this problem with css: a dynamic div contains a single line of text that I need to be wrapped every time the div resizes its width to a smaller size.
But my problem is that the text is inside the table. It is not a pure text, it actually serves as a directory of the contacts somehow like a paging.
Please refer to the images that I have attached for a better view of my problem. I also attached part of the code that I have below. See the attached image for a better understanding of the problem.
I'm not well versed in css, so I'm hoping you can suggest a better layout for this.
Hope you can help me. Thank you! :)
<div id="divSearch" style="width:350px">
<p style="word-wrap:break-word;white-space:pre-wrap;">
<table id="tblGlossary">
<tr>
<td class="glossary"><a href="#" >#</a></td>
<td align="right"> </td>
<td class="glossary">A</td>
<td align="right"> </td>
<td class="glossary">B</td>
<td align="right"> </td>
<td class="glossary">C</td>
<td align="right"> </td>
<td class="glossary">D</td>
<td align="right"> </td>
<td class="glossary">E</td>
<td align="right"> </td>
<td class="glossary">F</td>
<td align="right"> </td>
<td class="glossary">G</td>
<td align="right"> </td>
<td class="glossary">H</td>
<td align="right"> </td>
<td class="glossary">I</td>
<td align="right"> </td>
<td class="glossary">J</td>
<td align="right"> </td>
<td class="glossary">K</td>
<td align="right"> </td>
<td class="glossary">L</td>
<td align="right"> </td>
<td class="glossary">M</td>
<td align="right"> </td>
<td class="glossary">N</td>
<td align="right"> </td>
<td class="glossary">O</td>
<td align="right"> </td>
<td class="glossary">P</td>
<td align="right"> </td>
<td class="glossary">Q</td>
<td align="right"> </td>
<td class="glossary">R</td>
<td align="right"> </td>
<td class="glossary">S</td>
<td align="right"> </td>
<td class="glossary">T</td>
<td align="right"> </td>
<td class="glossary">U</td>
<td align="right"> </td>
<td class="glossary">V</td>
<td align="right"> </td>
<td class="glossary">W</td>
<td align="right"> </td>
<td class="glossary">X</td>
<td align="right"> </td>
<td class="glossary">Y</td>
<td align="right"> </td>
<td class="glossary">Z</td>
</tr>
</table>
</p>
</div>
I removed the <table> and replaced it with a <div> tag:
Live Demo
HTML:
<div id="divSearch" style="width:350px">
<p style="word-wrap:break-word;white-space:pre-wrap;">
<div id="tblGlossary">
#
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
</div>
</p>
</div>
CSS:
#tblGlossary a {
padding: 0 2px
}
Replace your entire table with a div without a fixed width:
<div id="divGlossary">
<a href="#" >#</a>
A
B
C
...
Since you already have the table inside a div, you can use that one.
The word-wrap property does not apply to table cells in the way that you want it.
You can't get a table to wrap. Well, I guess you could try to display: inline on everything...?
If you don't mind using a scrollbar, you can apply the following style :
#longlines {
clip : auto;
overflow : scroll;
}
that will fix your problem i hope let me know
<div width="10%" style="position: absolute; left: 2%; word-wrap:break-word;"> bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb </div> <div width="86%" style="position: absolute; left: 14%;word-wrap:break-word;"> bbbb </div>
Or
use <Span> </span> around your text