Wednesday, October 7, 2009

XML to HTML

Hi,
How can we convert XML datas into an HTML file?
Simple.
Step1:
Name the xml files as example.xml
Step2: The xml data should be like this. There will be CD tag which is used for conversion.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>

Step3: Create an HTML file as test.html

<html>
<body>

<script type="text/javascript">
if (window.XMLHttpRequest)
{
xhttp=new window.XMLHttpRequest();
}
else // Internet Explorer 5/6
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET","example.xml",false);
xhttp.send("");
xmlDoc=xhttp.responseXML;

document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("CD");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>

</body>
</html>

Step5: Run the test.html file,,and see the XML datas inside the CD tag will be converted into HTML table.
For more details... Here is the link

Google Check Out : Using Sandbox for Testing

Step1: We need to Create two gmail accounts for “Buyer” and “Merchant”. For example: samplebuyer@gmail.com and samplemerchant@gmail.com .

Step2: We need to create Sandbox Merchant and Buyer Accounts.
· Create a Sandbox buyer account with samplebuyer@gmail.com at http://sandbox.google.com/checkout
· Create a Sandbox merchant account with samplemerchant@gmail.com at http://sandbox.google.com/checkout/sell/
Step3: Follow these guidelines when setting up your test accounts:
· Name - Enter any text
· Billing Address - Enter any text
· City/Town - Enter any text
· State - Choose any state or territory from the menu
· Zip Code - Enter any valid five-digit or nine-digit zip code for the given state (the range of correct values is specified in the balloon help that appears)
· Phone Number - Enter a 10-digit number. For U.S. accounts, the first three digits must be a valid area code.
· Federal tax ID - Enter any 9 digits
· Social Security number - Enter any 9 digits
· Card Number - Use one of the credit card numbers in the following table:
Card Type Card Number Expiration Date CVC
American Express(see Note 1) 3782 8224 6310 005 any future date any four digits
Discover 6011 1111 1111 1117 any future date any three digits
MasterCard 5555 5555 5555 4444 any future date any three digits
VISA 4111 1111 1111 1111 any future date any three digits

Step4: After creating both sandbox accounts, we can Integrate our website with Google Checkout.
For adding a “Buy now button” into our site, we need to generate it using this link by Sign in using merchant account https://sandbox.google.com/checkout/sell2/settings?section=BuyNowButton
This will create a sample code, which is a form,,and the action will pointed to sandbox google check out.

Step5: Paste these code in an HTML page. By clicking it will redirect to Google check out page. Sign in using the samplebuyer@gmail.com and shop the product. Check the mail boxes of both accounts for getting the transaction details.

Step6: Thats all for a sample Google Check Out process. Now the Check out process happens between the Merchant and the buyer. For getting that response, Google Check out helps to provide a API Call back URL. Google will sent Check Out responses to this URL. For that we need to Sign in using “samplemerchant@gmai.com” to this link https://sandbox.google.com/checkout/sell/settings?section=Integration
Provide a cal back URL here For example: http://oursite.com/checkout
After completing the Google Check Out process, Google will hit on this http://oursite.com/checkout for giving the XML or HTML response with all Check Out details

Use this link for Getting response
http://code.google.com/p/google-checkout-php-sample-code/wiki/Documentation

--------------------------- Check these links---------------------
· http://code.google.com/apis/checkout/developer/Google_Checkout_Basic_HTML_Sandbox.html
· http://code.google.com/p/google-checkout-php-sample-code/wiki/Documentation

Tuesday, July 14, 2009

Will codeigniter??

An easy approach,,thats CodeIgniter.. Compared to Symfony, it is very simple and easy to integrate...
Check the Documentations

Thursday, June 18, 2009

Integrate Strophe IM into your symfony application

Hi all,

This is a brief procedure for integrating an IM application. Please read the links which are given below. And use the documentations in those sites properly.

Here are the steps for using an IM application into your symfony application (LAMP).
-------------------------------------------------------
1) XMPP is the protocol which is used for chat/IM applications. For using this, have to set up an Jabber/XMPP server and XMPP client. I used ejabberd : server and TrophyIM : (Which is a library developed based on Strophe) as client.

2) Follow these urls while setting up the ejabbered server
Link1
Link2

3) Download the TrophyIM and set the TROPHYIM_BOSH_SERVICE in the trophyim.js file as your http-bind server.

4) Add two users in the ejabberd admin

5) copy all the TrophyIM files into web folder in your symfony application.

6) run the index.html in your tempalets and login using the registered users from the ejabberd admin


Thanks.

Tuesday, June 16, 2009

Strophe : Jabber client Library

When coming to select a jabber client library , I prefer Strophe than Jwchat. Both are working on JavaScript. But Strophe is much more simple than JW chat. After all, Strophe has good and simple documentation for both API and Working.
Here is the documentations, Check this...
Documentation API
AND
Working

trophyim A JavaScript Jabber client

TrophyIM is a Jabber (XMPP) client built on top of strophe (http://code.stanziq.com/strophe/).

TrophyIM is a Jabber (XMPP) client built on top of strophe (http://code.stanziq.com/strophe/).

It is cross-browser compliant and should work in the newer versions of all the major browsers (IE, Firefox, Safari, Opera).

Click the source tab to check out the code itself, or you can download the current pre-release version (0.3). Check for the link to your right.

Installation: simply put trophyim.js in the same directory as your page, add to the header, and put a tag in your page wherever you want the client to load. TrophyIM will handle the rest, including loading strophe, which should be installed in ./strophejs/ relative to where TrophyIM is installed.

Feel free to IM me with any questions or comments, my jabber id is gar AT netflint.net

If you'd like to get a sense of where the project is, you can check out the more-or-less current working revision at http://trophy.im/

Thursday, May 28, 2009

link_to UrlHelper

In my application, I need one requirement that, when clicking on a link, it will open into a new window. But I am confused how I can do using link_to ( Url helper tag, which is used in Symfony). After searching it on Google I got the answer. Might be look like simple, "popup"=>"true"; this is the code that we have to add on the link_to. And also I would like to share some additional URL helper informations in this Post. Hope that this will useful for some one..

Options

  • :confirm => 'question?' - This will add a JavaScript confirm prompt with the question specified. If the user accepts, the link is processed normally, otherwise no action is taken.
  • :popup => true || array of window options - This will force the link to open in a popup window. By passing true, a default browser window will be opened with the URL. You can also specify an array of options that are passed-thru to JavaScripts window.open method.
  • :method => symbol of HTTP verb - This modifier will dynamically create an HTML form and immediately submit the form for processing using the HTTP verb specified. Useful for having links perform a POST operation in dangerous actions like deleting a record (which search bots can follow while spidering your site). Supported verbs are :post, :delete and :put. Note that if the user has JavaScript disabled, the request will fall back to using GET. If you are relying on the POST behavior, you should check for it in your controller’s action by using the request object’s methods for post?, delete? or put?.
  • The html_options will accept a hash of html attributes for the link tag