I have created the application that stores the Information about dogs in the database,while running the project the tables where created but dogs information were not updates.
There is an error in running this below html file
The following code is not working
<html lang="en">
<head>
<!-- META SECTION -->
<title>Dog Rescue</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- END META SECTION -->
<!-- BEGIN STYLE -->
<style>
table, th, td {
border: 1px solid black;
padding: 1px;
}
</style>
<!-- END STYLE -->
</head>
<body>
<h2>Current Dogs In Rescue</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Rescue Date</th>
<th>Vaccinated</th>
</tr>
</thead>
<tbody>
<tr th:each="dogs : ${dogs}">
<td th:text="${dogs.id}">Text ...</td>
<td th:text="${dogs.name}">Text ...</td>
<td th:text="${dogs.rescued}">Text ...</td>
<td th:text="${dogs.vaccinated}">Text...</td>
</tr>
</tbody>
</table>
</div>
<h2>Add A Dog</h2>
<form action="#" th:action="#{/}" method="post">
<label>Name<input type="text" name="name" id="name"></input></label>
<label>Vaccinated<input type="text" name="vaccinated" id="vaccinated"></input></label>
<label>Rescued<input type="text" name="rescued" id="rescued"></input></label>
<input type="submit" value="Submit"></input>
</form>
</body>
</html>
The html file is not fetching the information.
Kindly help me
Whole Project is available in
https://github.com/arulsuju/DogRescue.git
You are using the same variable name for iteration as the list variable (dogs)
, Consider using different name for iteration variable like (dog), so the code should be:
<tr th:each="dog : ${dogs}">
<td th:text="${dog.id}">Text ...</td>
<td th:text="${dog.name}">Text ...</td>
<td th:text="${dog.rescued}">Text ...</td>
<td th:text="${dog.vaccinated}">Text...</td>
</tr>
Related
Right now when I am parsing some html (front page of hacker news for example), it works fine. I can call class on something like doc = Nokogiri::HTML(open('news.ycombinator.com')) and I will get back Nokogiri::HTML::Document < Nokogiri::XML::Document
The issue is, in the terminal, I am seeing the HTML and not the actual Nokogiri Element. I want to see it because it shows me valuable info like the Nokogiri Elements Children, or an array of links or or or.
I get the HTML using the Watir Gem using the following method:
[1] pry(main)> browser = Watir::Browser.new(:firefox)
#<Watir::Browser:0x2c5654b29ef00c22 url="about:blank" title="">
[2] pry(main)> browser.goto('news.ycombinator.com')
"http://news.ycombinator.com"
[3] pry(main)> browser.html
Where browser.html is an instance variable (I think?) containing un-parsed HTML.
Here is what I get back right now if I call doc = Nokogiri::HTML.parse(browser.html)
And here is what I would like to get back:
Where am I going wrong?
adding raw code as requested:
Nokogiri::HTML::Document < Nokogiri::XML::Document
[31] pry(main)> doc = Nokogiri::HTML.parse(browser.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html op="news">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="referrer" content="origin">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="news.css?stXbi7LCyutClfTUMe1b">
<link rel="shortcut icon" href="favicon.ico">
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss">
<title>Hacker News</title>
</head>
<body>
<center><table id="hnmain" width="85%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f6ef">
<tbody>
<tr><td bgcolor="#ff6600"><table style="padding:2px" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr>
<td style="width:18px;padding-right:4px"><img src="y18.gif" style="border:1px white solid;" width="18" height="18"></td>
<td style="line-height:12pt; height:10px;"><span class="pagetop"><b class="hnname">Hacker News</b>
new | past | comments | ask | show | jobs | submit </span></td>
<td style="text-align:right;padding-right:4px;"><span class="pagetop">
login
</span></td>
</tr></tbody></table></td></tr>
<tr id="pagespace" title="" style="height:10px"></tr>
<tr><td>
<table class="itemlist" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr class="athing" id="19388248">
<td class="title" valign="top" align="right"><span class="rank">1.</span></td> <td class="votelinks" valign="top"><center><a id="up_19388248" href="vote?id=19388248&how=up&goto=news"><div class="votearrow" title="upvote"></div></a></center></td>
<td class="title">
Getting Too Absorbed in Your Side Projects<span class="sitebit comhead"> (<span class="sitestr">bennettnotes.com</span>)</span>
</td>
</tr>
<tr>
<td colspan="2"></td>
<td class="subtext">
<span class="score" id="score_19388248">42 points</span> by _davebennett <span class="age">1 hour ago</span> <span id="unv_19388248"></span> | hide | 27 comments </td>
</tr>
<tr class="spacer" style="height:5px"></tr>
<tr class="athing" id="19384878">
<td class="title" valign="top" align="right"><span class="rank">2.</span></td> <td class="votelinks" valign="top"><center><a id="up_19384878" href="vote?id=19384878&how=up&goto=news"><div class="votearrow" title="upvote"></div></a></center></td>
<td class="title">
Facebook’s Data Deals Are Under Criminal Investigation<span class="sitebit comhead"> (<span class="sitestr">nytimes.com</span>)</span>
</td>
</tr>
<tr>
<td colspan="2"></td>
<td class="subtext">
<span class="score" id="score_19384878">661 points</span> by tysone <span class="age">13 hours ago</span> <span id="unv_19384878"></span> | hide | 156 comments </td>
</tr>
<tr class="spacer" style="height:5px"></tr>
<tr class="athing" id="19388091">
<td class="title" valign="top" align="right"><span class="rank">3.</span></td> <td class="votelinks" valign="top"><center><a id="up_19388091" href="vote?id=19388091&how=up&goto=news"><div class="votearrow" title="upvote"></div></a></center></td>
<td class="title">
Krita 4.2.0: First painting application with HDR support on Windows<span class="sitebit comhead"> (<span class="sitestr">krita.org</span>)</span>
</td>
...
It sounds like you want:
doc = Nokogiri::HTML browser.html
I would like to click on the first row of the table as given below. (Ex on '5101170017') with vbscript code. with which I am trying to scrape the webpage info. How can I do this. as this webpage is password protected I can not share the details.
<html>
<head>
<script src='../../accidentweb/interface/DwrUtilsDao.js'></script>
<script src='../../accidentweb/engine.js'></script>
<script src='../../accidentweb/util.js'></script>
<base href="http://114.255.167.200:8092/cidasEN/extend/">
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<LINK href="css/css.css" type=text/css rel=stylesheet>
<title>Functional Query results</title>
</head>
<body bottomMargin=0 leftMargin=0 topMargin=0 >
<TABLE border="1" bordercolorlight="#6D6D6D" cellspacing="1"
bordercolordark="#C0C0C0" width="120%"
cellpadding="0" bgcolor="#FFFFFF" class=font9 style="BORDER-bottom: #4D5E8C 1px solid" >
<tr bgcolor="#CCCCCC" >
<td class="title_1" width ='6%' align="center">department</td>
<td class="title_1" width ='6%' align="center">case number</td>
<td class="title_1" width ='10%' align="center">time of accident</td>
<td class="title_1" width ='20%' align="center">location of scene of accident</td>
<td class="title_1" width ='6%' align="center">operator</td>
</tr>
<tr bgcolor="#FFFFFF" style="cursor:hand"
onmouseover="onmouseoverTR(this)"
onmouseout="onmouseoutTR(this)"
onclick="clearwsInfo('2017070100002','2017070100002',this);"
ondblclick='doSelect("auditflowForm","2017070100002");'>
<TD align="center">
<script type="text/javascript" >
outprint('ChengDu Branch');
</script>
</TD>
<TD align="center">
<script type="text/javascript" >
outprint('5101170017');
</script>
</TD>
<TD align="center">
<script type="text/javascript" >
outprint('2017-06-02 17:50');
</script>
</TD>
<TD align="left">
<script type="text/javascript" >
outprint('成赤高速成自段自贡往成都方向48km');
</script>
</TD>
<TD align="left">
<script type="text/javascript" >
outprint('杨东升');
</script>
</TD>
</TR>
<script anguage="javascript" >
//clearwsInfo("2017070100002","2017070100002","");
</script>
</TABLE>
</body>
</html>
I've tried the following:
Set iframe = IE.Document.getelementbyID("listInfoFrame")
For Each ele In iframe.contentDocument.getElementsByTagName("td")
msgbox(ele.innertext)
If InStr(ele.innertext, "department") > 0 Then
Set Row = ele.ParentNode.NextSibling
Row.Click
Exit For
End If
Next
I am getting an error as Permission Denied 'iframe.contentDocument. Any one can help me please
I keep encountering problems with my conditional comments for outlook desktop version. When viewing the email in outlook 2013 it is still showing it with border and the same font-size as for non-mso clients.
I also put the conditional comments in the head tag, but it did not work either.
If any of you can spot a typo or error somewhere in the code?
Thats the entire code I am using:
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Outlook conditional comments</title>
<meta charset="ISO-8859-1">
<meta name="description" content="">
<meta name="author" content="">
<meta name="keywords" content="">
</head>
<body>
<!--[if gte mso 9]>
<table class="lookout" border="0" cellpadding="0" cellspacing="0" align="left" style="max-width: 600px;
width: 100%; height: auto; font-size:3em;"> <tbody> <tr> <td>Increasing sales </td> </tr> </tbody> </table>
<![endif]-->
<table class="lookout" border="1" cellpadding="0" cellspacing="0" align="center" style="max-width: 600px; width: 100%; height: auto; font-size:1em;">
<tbody>
<tr>
<td>Increasing Sales</td>
</tr>
</tbody>
</table>
</body>
</html>
Many thanks in advance
Danie
It is showing the border because the second <table> is not hidden from Outlook. Outlook 2007/10/13/16 displays both <table>s.
We want to write two tables and wrap each in an <mso> tag: one that displays a <table> only for Outlook 2007/10/13/16, and one that hides a <table> only for Outlook 2007/10/13/16. Something like this:
<body>
<!--[if gte mso 9]>
<table class="lookout" border="0" cellpadding="0" cellspacing="0" align="left" style="max-width: 600px;
width: 100%; height: auto; font-size:3em;">
<tbody>
<tr>
<td>Increasing sales In Outlook 2007/10/13/16</td>
</tr>
</tbody>
</table>
<![endif]-->
<!--[if !mso 9]><!-->
<table class="lookout" border="1" cellpadding="0" cellspacing="0" align="center" style="max-width: 600px; width: 100%; height: auto; font-size:1em;">
<tbody>
<tr>
<td>Increasing Sales everywhere else</td>
</tr>
</tbody>
</table>
<!--<![endif]-->
It shows with a Border and font-size bacause the Bottom Table isn't hidden. Also I most times use this Term: <!--[if (gte mso 9)|(IE)]> It seems to work the best for most MSO Clients
#Niklas and #Ted: many thanks for your replies.
I did another attempt and sent the email exactly the way you suggested Ted, but unfortunately the border and 1em font-size were there again in Outlook 2013.
I was wonder whether the email client it is sent from can have an impact on how it is displayed in the email client it is viewed later on. I sent it from gmail. I saved the html doc from the browser and copied it over to gmail.
This is how the html file I copied looks like:
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Outlook conditional comments</title>
<meta charset="ISO-8859-1">
<meta name="description" content="">
<meta name="author" content="">
<meta name="keywords" content="">
</head>
<body>
<!--[if gte mso 9]>
<table class="lookout" border="0" cellpadding="0" cellspacing="0" align="left" style="max-width: 600px;
width: 100%; height: auto; font-size:3em;"> <tbody> <tr> <td>Increasing sales 13</td> </tr> </tbody> </table>
<![endif]-->
<!--[if !mso 9]> <!-->
<table class="lookout" border="1" cellpadding="0" cellspacing="0" align="center" style="max-width: 600px; width: 100%; height: auto; font-size:1em;">
<tbody>
<tr>
<td>Increasing Sales everwhere else</td>
</tr>
</tbody>
</table>
<!--<![endif]-->
</body>
</html>
Any thoughts or comment on the new code are highly appreciated.
Danie
When I use Flying Saucer to convert html page with Chinese character. The Chinese character displayed as a box like below
I have tried both methods: using the css as in this answer Flying Saucer font for unicode characters and using the code as in this answer Flying Saucer iTextPDF Chinese Fonts, but they did not work. Does anyone have another suggestion?
I have declared the UTF-8 charset in meta tag as below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html language="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"> </meta>
<link rel="stylesheet" type="text/css" href="file:///opt/template/employer.css"/>
<link rel="stylesheet" type="text/css" href="file:///opt/template/style.css"/>
<link rel="stylesheet" type="text/css" media="print" href="file:///opt/template/print.css"/>
</head>
Here is the relevant section with the chinese characters:
<tbody><tr>
<td align="left" width="150" valign="top">
Name
</td>
<td align="left" width="305" valign="top">
<label id="candidateName">VU DINH THE / 你好</label>
</td>
</tr>
<tr>
<td align="left" width="150" valign="top">
Gender/Status
</td>
<td align="left" width="305" valign="top">
<label id="gender">Female</label> / <label id="status">Single
</label>
</td>
</tr>
<tr>
<td align="left" width="150" valign="top">
Date of Birth/Age
</td>
<td align="left" width="305" valign="top">
<label id="dob">12 Sep 1985</label> / <label id="age">30</label>
</td>
</tr>
And the content of print.css:
#font-face {
font-family: Arial Unicode MS;
src: url('file:///opt/template/arialuni.ttf');
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
Replacement of a character by an empty square or rectangle usually means that the character is not defined in the font file, and the system doesn't find information to draw it.
In this case, the HTML and CSS code is correct, but the arialuni.ttf file is incomplete.
For reference, the arialuni.ttf should be ~23 MB.
I am using Spring MVC 3 and Thymeleaf. I want to display string in the table but there are no results (blank table cell). What am I doing wrong? My controller class:
#Controller
#RequestMapping(value="table", method = RequestMethod.GET)
public class TableController {
#Autowired
DaneEndpoint daneEndpoint;
public String tabela(Model model){
model.addAttribute("tytul", daneEndpoint.getAll().get(0));
model.addAttribute(model);
return "table";
}
}
and html page (table.html):
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h3 align="center">table</h3>
<div align="left">
<form action="table.html" th:object="${tytul}" method="get">
<fieldset>
<div align="center">
<table border="1">
<thead>
<tr>
<th th:text="">tytul</th>
</tr>
</thead>
<tbody>
<tr>
<td th:text=""><span th:text="#{table.tytul}"/></td>
</tr>
</tbody>
</table>
</div>
</fieldset>
</form>
</div>
</body>
</html>
Thanks for help.
<span th:text="#{table.tytul}"/>
`
fetches value from message properties so if table.html is opened directly in browser,it will be blank
If this page is accessed through application, since ,
<th th:text="">
is not valid thymeleaf expression syntax(because of empty string) , parse error will occur.. And
<td th:text=""><span th:text="#{table.tytul}"/></td>
contains span as child of td so, th:text need not be included in td as th:text in td will replace ultimately..
further meta tag is not closed..
Try this
> <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head>
> <title></title>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> </head> <body>
> <h3 align="center">table</h3>
> <div align="left">
> <form action="table.html" th:object="${tytul}" method="get">
> <fieldset>
> <div align="center">
> <table border="1">
> <thead>
> <tr>
> <th >tytul</th>
> </tr>
> </thead>
> <tbody>
> <tr>
> <td><span th:text="#{table.tytul}"/></td>
> </tr>
> </tbody>
> </table>
> </div>
> </fieldset>
> </form>
> </div> </body> </html>
And if value on table need to be displayed when directly opened in browser for prototyping purpose, try this
> <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head>
> <title></title>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body>
> <h3 align="center">table</h3>
> <div align="left">
> <form action="table.html" th:object="${tytul}" method="get">
> <fieldset>
> <div align="center">
> <table border="1">
> <thead>
> <tr>
> <th >tytul</th>
> </tr>
> </thead>
> <tbody>
> <tr>
> <td><span th:text="#{table.tytul}"/> <span th:remove="all">content</span></td>
>
> </tr>
> </tbody>
> </table>
> </div>
> </fieldset>
> </form>
> </div> </body> </html>
Seems like you were missing an ending </tr> and ending </div>. try adding that.