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