I implemented ccavenue integration in my android app
ccavenue returns html string
I need to read html body content and table rows from that string
Below is html string
<head><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Response Handler</title>
</head>
<body>
<center>
<font size="4" color="blue"><b>Response Page</b></font>
<table border="1">
<tbody><tr>
<td>merchant_param5 </td>
<td> </td>
</tr>
<tr>
<td>merchant_param4 </td>
<td> </td>
</tr>
<tr>
<td>merchant_param3 </td>
<td> </td>
</tr>
<tr>
<td>billing_name </td>
<td> Amit </td>
</tr>
<tr>
<td>merchant_param2 </td>
<td> </td>
</tr>
<tr>
<td>status_message </td>
<td> Payment failed due to a technical error with the bank. Please retry after some time. </td>
</tr>
<tr>
<td>merchant_param1 </td>
<td> </td>
</tr>
<tr>
<td>billing_city </td>
<td> Nashik </td>
</tr>
<tr>
<td>amount </td>
<td> 1.0 </td>
</tr>
<tr>
<td>order_status </td>
<td> Failure </td>
</tr>
<tr>
<td>billing_country </td>
<td> India </td>
</tr>
<tr>
<td>response_code </td>
<td> 0 </td>
</tr>
<tr>
<td>billing_address </td>
<td> Nashik </td>
</tr>
<tr>
<td>billing_notes </td>
<td> </td>
</tr>
<tr>
<td>discount_value </td>
<td> 0.0 </td>
</tr>
<tr>
<td>retry </td>
<td> N </td>
</tr>
<tr>
<td>billing_zip </td>
<td> 422005 </td>
</tr>
<tr>
<td>delivery_country </td>
<td> India </td>
</tr>
<tr>
<td>billing_tel </td>
<td> 9404005390 </td>
</tr>
<tr>
<td>failure_message </td>
<td> </td>
</tr>
<tr>
<td>order_id </td>
<td> 6355706 </td>
</tr>
<tr>
<td>bank_ref_no </td>
<td> null </td>
</tr>
<tr>
<td>delivery_address </td>
<td> Nashik </td>
</tr>
<tr>
<td>status_code </td>
<td> null </td>
</tr>
<tr>
<td>billing_state </td>
<td> Maharashtra </td>
</tr>
<tr>
<td>payment_mode </td>
<td> Wallet </td>
</tr>
<tr>
<td>vault </td>
<td> N </td>
</tr>
<tr>
<td>delivery_state </td>
<td> Maharashtra </td>
</tr>
<tr>
<td>offer_type </td>
<td> null </td>
</tr>
<tr>
<td>bin_country </td>
<td> </td>
</tr>
<tr>
<td>delivery_name </td>
<td> Amit </td>
</tr>
<tr>
<td>offer_code </td>
<td> null </td>
</tr>
<tr>
<td>tracking_id </td>
<td> 106246806219 </td>
</tr>
<tr>
<td>delivery_city </td>
<td> Nashik </td>
</tr>
<tr>
<td>trans_date </td>
<td> 01/07/2017 20:27:58 </td>
</tr>
<tr>
<td>delivery_zip </td>
<td> 422005 </td>
</tr>
<tr>
<td>delivery_tel </td>
<td> 9404005390 </td>
</tr>
<tr>
<td>currency </td>
<td> INR </td>
</tr>
<tr>
<td>eci_value </td>
<td> null </td>
</tr>
<tr>
<td>card_name </td>
<td> Paytm </td>
</tr>
<tr>
<td>billing_email </td>
<td> desale.amit#gmail.com </td>
</tr>
<tr>
<td>mer_amount </td>
<td> 1.0 </td>
</tr>
</tbody></table>
</center>
</body></head>
I need to parse above html string
how to parse this string
please suggest
thanks
You can use JSOUP to fetch your data as String
1.) Get the string as Document using Jsoup.parse(your_string)
2.) Get all nodes using document.getAllElements() as Elements
3.) Traverse the elements and use ownText() function to fetch data
Document document=Jsoup.parse(your_response);
Elements elements = document.getAllElements();
for (Element element : elements) {
String data =element.ownText();
// some strings are empty so avoid them
if (!data.isEmpty()) {
System.out.println(data);
}
}
output
Response Handler
Response Page
merchant_param5
merchant_param4
merchant_param3
billing_name
Amit
... data
... more data
desale.amit#gmail.com
mer_amount
1.0
You can use Jsop lib or Htmlcleaner
Related
Only on Android 6 all my Buttons looks different. Even in Outlook 10 the Buttons looks i expected. I don't understand that..Or is this a Litmus Bug?
Here ist my Button-Code Foundation Zurb Email):
<table class="button small-float-center"
style="Margin:0 0 16px 0;border-collapse:collapse;border-spacing:0;margin:0 0 16px 0;padding:0;
text-align:left;vertical-align:top;width:auto">
<tbody>
<tr style="padding:0;text-align:left;vertical-align:top">
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;
color:#000;font-family:Helvetica,Arial,sans-serif;font-size:14px;font-weight:400;
hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
<tbody>
<tr style="padding:0;text-align:left;vertical-align:top">
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:#fff;
border:1px solid #000;border-collapse:collapse!important;color:#000;font-family:Helvetica,Arial,sans-serif;font-size:14px;
font-weight:400;hyphens:auto;letter-spacing:1px;line-height:1.3;margin:0;padding:1px 12px;text-align:center;vertical-align:top;
word-wrap:break-word">
<a href="#" style="Margin:0;border:0 solid #fff;border-radius:0;color:#000;display:inline-block;
font-family:Helvetica,Arial,sans-serif;font-size:11px;font-weight:400;line-height:1.3;margin:0;
padding:7px 5px 7px 5px;text-align:left;text-decoration:none">WEITERLESEN</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
There is extra white space on my HTML email between the header.png and the body.png image (their table rows, actually). I cant for the life of me figure out why this is happening. It only happens on Gmail for Android and not on Gmail for Iphone. Here is the code:
<body topmargin="0">
<table align="center" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse; border-spacing:0; border: none; border: 1px solid #b76f49">
<tr>
<td width="600" style="display:block !important;">
<table cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse; border-spacing:0;">
<tr>
<td width="600" style="line-height:0;">
<table cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse; border-spacing:0;line-height:0;font-size:1px;">
<tr>
<td width="17" style="line-height:0;min-width:17px;">
<img src="headerleft.png" width="17" style="display:block !important; line-height:0;font-size:1px;" align="absbottom">
</td>
<td width="567" style="line-height:0;min-width:567px;">
<img alt="" border="0" width="567" src="header.png" style="display:block !important; line-height:0;font-size:1px;" align="absbottom">
</td>
<td width="16" style="line-height:0;min-width:16px;">
<img src="headerright.png" width="16" style="display:block !important; line-height:0;font-size:1px;" align="absbottom">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="600" style="display:block !important;">
<table cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse; border-spacing:0;">
<tr>
<td width="17" style="border-right:3px solid #b76f49; min-width:17px; font-size:1px;">
<img src="bodyleft.png" width="17" border="0" style="display:block !important; line-height:0; font-size:1px;">
</td>
<td width="561">
<table cellpadding="0" cellspacing="0" width="561" style="border-collapse: collapse; border-spacing:0;">
<tr>
<td width="20" style="font-size:1px;">
</td>
<td width="357" valign="top" style="font-family: Arial; font-size: 14px; font-color: #000;">
<p style="font-family:Arial; font-size: 16px; font-weight: bold; color:#004685;">HEader</p>
Hello,<br><br>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</td>
<td width="184" style="min-width:184px;">
<img src="bodyrightimage.png" width="170" height="400" border="0" align="right" style="font-size: 1px; line-height:0px; display:block!important;">
</td>
</tr>
</table>
</td>
<td width="30" style="border-left:3px solid #b76f49;min-width:30px;">
<img src="bodyright.png" height="400" width="16" border="0" style="display:block !important; line-height:0; font-size: 1px;">
</td>
</tr>
</table>
</td>
</tr>
HTML counts line breaks as whitespace, so if you're using table cells (ick) for layout purposes, then this code:
<tr>
<td>
<img ... />
^---line break here
</td>
^^^---indentation whitespace here
<td>
<img ... />
</d>
</tr>
will be rendered as
[img] [img]
^----linebreak+indentation as whitespace
Simple solution: don't put your </td> on a separate line:
<tr>
<td><img ../></td>
<td><img ../></td>
</tr>
In my app i wanna display a html data in web view.I tried it ,but the html data is not being displayed in the webview.Please do help me out
Code
webView = (WebView) view.findViewById(R.id.webView);
if (!strSendTo.equals("")) {
etSendTo.setText(strSendTo);
}
if (!htmlData.equals("")) {
webView.loadData(htmlData, MIME_TYPE, ENCODING);
}
Html
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<TABLE border=0 cellSpacing=0 cellPadding=10 background=#FFFFFF align=center>
<TBODY>
<TR>
<TD vAlign=top>
<TABLE style=MARGIN-TOP: 40px border=0 cellSpacing=0 cellPadding=0 width=709 align=center>
<TBODY>
<TR>
<TD> </TD>
</TR>
<TR>
<TD>
<P>
<STRONG>Hello Jadya ,</STRONG>
</P>
<P>Please check your expenses of trip 'Goa' dated from 14/04/2015 to 23/04/2015.</P>
</TD>
</TR>
<TR>
<TD height=15></TD>
</TR>
<TR>
<TD>
<TABLE border=1 cellSpacing=0 cellPadding=5>
<TBODY>
<TR>
<TD height=30 colSpan=6 align=middle>
<STRONG>Credit / Contribution </STRONG>
</TD>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Category</STRONG>
</TD>
<TD width=120 noWrap align=right>
<STRONG>Amount</STRONG>
</TD>
</TR>
<TR>
<TD noWrap align=left>Contribution</TD>
<TD noWrap align=right>1000.00</TD>
</TR>
<TR>
<TD noWrap align=left>Expenses</TD>
<TD noWrap align=right>0.00</TD>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Total</STRONG>
</TD>
<TD width=120 noWrap align=right>
<STRONG>1000.00</STRONG>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD height=15></TD>
</TR>
<TR>
<TD height=8>
<TABLE border=1 cellSpacing=0 cellPadding=5>
<TBODY>
<TR>
<TD height=30 colSpan=6 align=middle>
<STRONG>Payable Amount</STRONG>
</TD>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Category</STRONG>
</TD>
<TD width=120 noWrap align=right>
<STRONG>Amount</STRONG>
</TD>
</TR>
<TR>
<TD noWrap align=left>Drink</TD>
<TD noWrap align=right>40.00</TD>
</TR>
<TR>
<TD noWrap align=left>Entertainment</TD>
<TD noWrap align=right>200.00</TD>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Total</STRONG>
</TD>
<TD width=120 noWrap align=right>
<STRONG>240.00</STRONG>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD height=15></TD>
</TR>
<TR>
<TD height=8> </TD>
</TR>
<TR>
<TD style=BACKGROUND-REPEAT: repeat-x ; HEIGHT: 2px; BACKGROUND-POSITION: center 140px; background=></TD>
</TR>
<TR>
<TD height=8>
<TABLE border=0 cellSpacing=0 cellPadding=5>
<TBODY>
<TR>
<TD height=30 colSpan=6 align=left>
<h3><u>Net Balance</u></h3></TD>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Credit / Contribution</STRONG>
</TD>
<TD width=120 noWrap align=right>1000.00</TD>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Payable</STRONG>
</TD>
<TD width=120 noWrap align=right>-240.00</TD>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Amount Received From</STRONG>
</TD>
<TD width=120 noWrap align=right>-0.00</TD>
</TR>
<TR>
<TD colspan=2>
<HR size=1> </td>
</TR>
<TR>
<TD width=140 noWrap align=left>
<STRONG>Net Balance</STRONG>
</TD>
<TD width=120 noWrap align=right>
<STRONG>760.00</STRONG>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD style=BACKGROUND-REPEAT: repeat-x ; HEIGHT: 2px; BACKGROUND-POSITION: center 140px; background=></TD>
</TR>
<TR>
<TD height=8></TD>
</TR>
<TR>
<TD height=8></TD>
</TR>
<TR>
<TD height=8 width=709></TD>
</TR>
<TR>
<TD style=BACKGROUND-REPEAT: repeat-x; BACKGROUND-POSITION: center 140px; background=></TD>
</TR>
<TR>
<TD height=8></TD>
</TR>
<TR>
<TD height=8></TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
From the WebView Class official page :
http://developer.android.com/reference/android/webkit/WebView.html
String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", null);
and why your Html tags are uppercase?
I'm currently at a stand still and could really use some help. I'm coding an HTML email which is a first for me. I have a basic understanding of CSS and HTML, but I can't figure out for the life of me how to fix this Gmail problem, and I even know what the cause is. It seems as though the problem is coming from the only editable text region, which is the address line (Hi [name],) and which is also the only row with multiple columns. It looks like the text isn't shrinking to fit the screen, causing the neighboring cells to go crazy and expand the picture. It works great in every other ESP I tested it on, even Outlook. I attached a picture and my code. Please, if you have any advice or resources please help a noob in need.
messed up version on Android Gmail app
code
<html>
<head>
<title>Tradeshow_email_PARTY</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Tradeshow_email_PARTY.jpg) -->
<table id="Table_01" width="600" height="1046" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3">
<img src="http://i.imgur.com/m2GZSwm.png" style="display:block" width="600" height="408" alt="">
</td>
</tr>
<tr>
<td>
<img src="http://i.imgur.com/RyJDbPa.png" style="display:block" width="47" height="40" alt="">
</td>
<td width="123" height="40" style="line-height: 0pt; font-weight: bolder;"><font face="arial" size="2px" color="#636564">Hi [name],</font>
</td>
<td>
<img src="http://i.imgur.com/KUO971D.png" style="display:block" width="430" height="40" alt="">
</td>
</tr>
<tr>
<td colspan="3">
<img src="http://i.imgur.com/nWU4N6L.png" style="display:block" width="600" height="598" alt="">
</td>
</tr>
</table>
<!-- End Save for Web Slices -->
</body>
You should nest your columns instead of colspanning it. Setting widths on the all table cells that are not 100% of the row is important also. Example:
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Tradeshow_email_PARTY.jpg) -->
<table id="Table_01" width="600" height="1046" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="http://i.imgur.com/m2GZSwm.png" style="display:block" width="600" height="408" alt="">
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="47">
<img src="http://i.imgur.com/RyJDbPa.png" style="display:block" width="47" height="40" alt="">
</td>
<td width="123" height="40" style="font-family: Arial, Helvetica, sans-serif; font-size:12px; font-weight: bold; color:#636564;">
Hi [name],
</td>
<td width="40">
<img src="http://i.imgur.com/KUO971D.png" style="display:block" width="430" height="40" alt="">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img src="http://i.imgur.com/nWU4N6L.png" style="display:block" width="600" height="598" alt="">
</td>
</tr>
</table>
<!-- End Save for Web Slices -->
</body>
You'll notice a few other small things I fixed up for you also. Ultimately though, you are using a lot of images in places where you shouldn't. Your grey sides should be in html and so should all text from the red area down.
This is my try based on above code:
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Tradeshow_email_PARTY.jpg) -->
<table width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="http://i.imgur.com/m2GZSwm.png" style="display:block" width="600" height="408" alt="">
</td>
</tr>
<tr>
<td width="600" style="width:600px;min-width:600px;max-width:600px;">
<table width="600" border="0" cellpadding="0" cellspacing="0" style="border-collapse:separate;">
<tr>
<td width="47" style="width:47px;;min-width:47px;padding:0px;margin:0px;">
<img src="http://i.imgur.com/RyJDbPa.png" style="display:block;min-width:47px;width:47px;" width="47" height="40" alt="">
</td>
<td width="123" style="font-family: Arial, Helvetica, sans-serif; font-size:12px; font-weight: bold; color:#636564;width:123px;min-width:123px;">
Hi [name],
</td>
<td width="430" style="width:430px;min-width:430px;">
<img src="http://i.imgur.com/KUO971D.png" style="display:block;width:430px;min-width:430px;" width="430" height="40" alt="">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img src="http://i.imgur.com/nWU4N6L.png" style="display:block" width="600" height="598" alt="">
</td>
</tr>
</table>
<!-- End Save for Web Slices -->
</body>
<form action="test2.html" method="POST" autocomplete="on" id="myForm" >
<table>
<tr>
<td>
Name:
</td>
<td>
<input type="text" id="text1" pattern="[A-z]{3}"/><br/>
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
<input type="email" id="mail" autofocus="autofocus"/><br/>
</td>
</tr>
<tr>
<td>
URL:
</td>
<td>
<input type="url" id="url"/><br/>
</td>
</tr>
<tr>
<td>
Number:
</td>
<td>
<input type="number" id="num" required="required" onSubmit="click()"/><br/>
</td>
</tr>
<tr>
<td>
Date:
</td>
<td>
<input type="date" id="dat"/><br/>
</td>
</tr>
<tr>
<td>
Range:
</td>
<td>
<input type="range" id="range" min="1" max="10"/><br/>
</td>
</tr>
<tr>
<td>
Search:
</td>
<td>
<input type="search" id="search" placeholder="Search W3Schools" /><br/>
</td>
</tr>
<tr>
<td>
Color:
</td>
<td>
<input type="color"/><br/>
</td>
</tr>
<tr>
<td>
DataList:
</td>
<td>
<input type="url" list="url_list" name="link" />
<datalist id="url_list">
<option label="W3Schools" value="http://www.w3schools.com" />
<option label="Google" value="http://www.google.com" />
<option label="Microsoft" value="http://www.microsoft.com" />
</datalist><br/>
</td>
</tr>
<tr>
<td>
Points:
</td>
<td>
<input type="number" name="points" min="0" max="10" step="3" /><br/>
</td>
</tr>
<tr>
<td>
Output:
</td>
<td>
<output id="result" onforminput="45"></output><br/>
</td>
</tr>
<tr>
<td>
Image
</td>
<td>
<input type="image" src="client.png" width="40" height="40" /><br/>
</td>
</tr>
<tr>
<td>
<input type="submit" value="submit"/>
</td>
</tr>
</table>
</form>
This is the form that runs fine in "chrome" but whn i try and run it on android emulator, none of the validations seem to work. Any suggestions on what can be done?
Also, when i enter value in a textbox, it automatically takes in the value of prev textbox and appends it, Any suggestions on what can be done abt that?
I do not think Andriod supports HTML5 form validation. May find this link useful: Form Validation Support
Maybe something like Modernizr might be good, but maybe JavaScript is your best bet.