Parsing XML with JQuery without adding plugin
jQuery is great library for developing ajax based application. jQuery is great library for the JavaScript programmers, which simplifies the development of web 2.0 applications.
You can use simple JavaScript to perform all the functions that jQuery provides. Then why jQuery? The jQuery library is providing many easy to use functions and methods to make rich applications. These functions are very easy to learn and even a designer can learn it fast. Due to these features jQuery is very popular and in high demand among the developers. You can use jQuery in all the web based applications irrespective of the technology.
jQuery Plugin: jParse that allows you to quickly and easily parse XML. While this is a great plugin and does exactly as it says, I personally try not to use too many plugins in my JavaScript Programing. So I decided to write a tutorial to show you how easy it actually is to Parse XML via jQuery.
Lets first take a look at the XML file we are going to Parse. The XML document is saved as cd_catalog.xml.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?xml version="1.0" encoding="utf-8" ?>
<CATALOG>
<CD type="physcial">
<TITLE>Maggie May</TITLE>
<ARTIST>Rod Stewart</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Pickwick</COMPANY>
<PRICE>8.50</PRICE>
<YEAR>1990</YEAR>
</CD>
<CD type="physical">
<TITLE>When a man loves a woman</TITLE>
<ARTIST>Percy Sledge</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Atlantic</COMPANY>
<PRICE>8.70</PRICE>
<YEAR>1987</YEAR>
</CD>
<CD type="digital">
<TITLE>Big Willie style</TITLE>
<ARTIST>Will Smith</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1997</YEAR>
</CD>
</CATALOG>
|
As you see this is a simple XML document of a CD Catalog. If you have never seen an XML document before I suggest you read up on it. Now lets look at the jQuery Code we will use to extract the data. I am going to post the full code and then explain what each line does. If you don’t care what each line does then feel free to copy and paste and augment the code. Anyway here is the code.
1 2 3 4 5 6 7 8 9 10 11 12 |
$(document).ready(function(){
$.ajax({
type: "GET",
url: "cd_catalog.xml",
dataType: "xml",
success: function(xml){
$(xml).find("CD").each(function(){
$("#CD").append($(this).find("ARTIST").text() + "<br />");
});
}
});
});
|
The output of the jQuery code would look something like this:
1 2 3 |
Rod Stewart<br /> Percy Sledge<br /> Will Smith<br /> |
So now that you see the code let me explain. First you must call the $.Ajax Get Request in order to actually get the XML file. (On a side note you may also use jQuery’s $.get function to retrieve the XML document.) Click here if you don’t understand the $.Ajax Get Request. When you successfully get the cd_catalog.xml file you must call a function to process the XML. Then on Line 7 in the jQuery code
$(xml).find(”CD”).each(function() is how you actually process the XML data. First you must use the .find to search all “CD” tags in the XML document then use the .each to loop through every “CD” tag that is in the XML document. Now that we are looping through the all “CD” tags, we can output the Artist Name by using the following code on line
8 $(”#CD”).append($(this).find(”ARTIST”).text() + “br/”);. We must first Append data to the div with the ID CD in the HTML document. The data that we will append to the div is as follows: $(this).find(”ARTIST”).text().
What we do here is find the tag “ARTIST” within the “CD” Node and get the text within the “ARTIST” tag. As you see its pretty simple to Parse an XML document with jQuery. But there is one more topic I want to cover and that is XML tag Attributes.
In the XML document above you can see that in the “CD” tag we have an attribute called “type”. To access an attribute you can use the code below after line 7 in the above jQuery code.
1 |
$(this).attr("type")
|
And that is it for this tutorial. We hope it will help you on your quest to become a jQuery guru.
Cheers
How “Ajax” Works!
In traditional JavaScript coding, if you want to get any information from a database or a file on the server, or send user information to a server, you will have to make an HTML form and GET or POST data to the server. The user will have to click the “Submit” button to send/get the information, wait for the server to respond, and then a new page will load with the results.
Because the server returns a new page each time the user submits input, traditional web applications can run slowly and tend to be less user-friendly. With AJAX, your JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object.
With an HTTP request, a web page can make a request to, and get a response from a web server, without reloading the page. The user will stay on the same page, and he or she will not notice that scripts request pages, or send data to a server in the background.
This is a simplified introduction about how Ajax works
The user sends a request that executes an action and the action’s response is showed into a layer, identify by an ID, without reload the full page. For example a layer with this id:
<div id=”ajaxResponse”></div>
In the next steps we will see how to create an XMLHttpRequest and receive response from the server.
1. Create XMLhttpRequest
Different browsers use different methods to create the XMLHttpRequest object. Internet Explorer uses an ActiveXObject, while other browsers use the built-in JavaScript object called XMLHttpRequest.
To create this object, and deal with different browsers, we are going to use a “try and catch” statement.
function ajaxFunction()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(”Msxml2.XMLHTTP”);
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject(”Microsoft.XMLHTTP”);
}
catch (e)
{
alert(”Your browser does not support AJAX!”);
return false;
}
}
}
2. Sending request to the server
To send off a request to the server, we use the open() method and the send() method.
The open() method takes three arguments. The first argument defines which method to use when sending the request (GET or POST). The second argument specifies the URL of the server-side script. The third argument specifies that the request should be handled asynchronously. The send() method sends the request off to the server.
xmlHttp.open(”GET”,”time.asp”,true);
xmlHttp.send(null);
3. Writing server side script
The responseText will store the data returned from the server. Here we want to send back the current time. The code in “time.asp” looks like this:
<%
response.expires=-1
response.write(time)
%>
4. Consuming the response
Now we need to consume the response received and display it to the user.
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.myForm.time.value=xmlHttp.responseText;
}
}
xmlHttp.open(”GET”,”time.asp”,true);
xmlHttp.send(null);
}
5. Complete the code
Now we must decide when the AJAX function should be executed. We will let the function run “behind the scenes” when the user types something in the username text field. The complete code looks like this:
<html>
<body>
<script type=”text/javascript”>
function ajaxFunction()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(”Msxml2.XMLHTTP”);
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject(”Microsoft.XMLHTTP”);
}
catch (e)
{
alert(”Your browser does not support AJAX!”);
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.myForm.time.value=xmlHttp.responseText;
}
}
xmlHttp.open(”GET”,”time.asp”,true);
xmlHttp.send(null);
}
</script>
<form name=”myForm”>
Name: <input type=”text”
onkeyup=”ajaxFunction();” name=”username” />
Time: <input type=”text” name=”time” />
</form>
</body>
</html>
What is an eBook? “Go Green, Save Green”
Definition: An eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader.
Usually much shorter in the number of pages when compared to a traditional printed and bound book, eBooks are still useful as they can contain bookmarks that make it easy to jump to specific sections, they may contain colurful illustrations, they can contain active links to websites and you can print only the pages you want.
Since eBooks can be published for a fraction of the cost of publishing a traditional book they are typically far less expensive to buy than a bound book. In many cases, eBooks are offered free as a form of business promotion.
Most ebooks that are available on websites are published in PDF format. PDF format is very popular because Adobe Reader and other software that provides the ability to open PDF documents is now typically included on every computer sold and PDF’s can easily be read on both Windows PCs and Macs. PDF eBooks therefore make it easy to open and read the material without needing to download any software or have any special hardware, such as an eBook reader.
Many readers find eBooks to be more convenient than bound books, especially for information that changes frequently. The time to publish eBooks can be as little as a few minutes once the content is properly formatted. Therefore, eBook publishers can distribute updated versions easily and inexpensively.
Some eBooks can be downloaded for free or at reduced cost, however, prices for many eBooks – especially bestsellers – are similar to those of hardcover books, and are sometimes higher. Most eBooks at Barnes and Noble, for example, are comparable in price to their traditional print versions.
Communicate exactly as you intend
Although it is not necessary to use a reader application or device in order to read an Ebook (most books can be read as PDF files), they are popular because they enable options similar to those of a paper book – readers can bookmark pages, make notes, highlight passages, and save selected text. In addition to these familiar possibilities, eBook readers also include built-in dictionaries, and alterable font sizes and styles. Typically, an eBook reader hand-held device weighs from about twenty-two ounces to three or four pounds and can store from four thousand to over half a million pages of text and graphics. A popular feature is its back-lit screen (which makes reading in the dark possible).
Some eBooks can be downloaded for free or at reduced cost, however, prices for many eBooks – especially bestsellers – are similar to those of hardcover books, and are sometimes higher. Most eBooks at Barnes and Noble, for example, are comparable in price to their traditional print versions.
Do more with your PDF files
- Share your PDF and other files as a link, avoiding the need for email attachments.
- Embed your PDF in your website, blog or wiki
Pronunciation: eee books
Also Known As: PDF books
Alternate Spellings: e-books
Examples: Selling eBooks online is one type of home business that is popular with those who want to generate income from the Internet while working from home. Because eBooks are transmitted electronically, there is no need to carry a physical inventory of books for sale.
People love PDF so much :)
“Go Green, Save Green”
How to market during holiday
This is the season once more! Amid the chestnuts, open fires, and mistletoes, holiday cheer signals the busy season for marketers. How can you meet consumer needs, especially during a recession? Over on Open Forum, Julia Rogers from Recession wire has several suggestions:
• Bring your customers together.
• Ask your prospects and clients what’s on their holiday wish list through surveys … and give yourself the gift of case studies and testimonials from satisfied clients.
• Create a “12 days of different products and services” promotion.
• Emphasize family in your marketing campaigns.
Click over to the article for explanations. On one hand, I sometimes feel like resenting the marketing and commercialism surrounding the holidays. On the other, I have to sometimes admit that the holidays wouldn’t be the same without heartwarming sweater ads, multi-colored Oreos, and this year’s John Krasinski in Gap ads. The Macy’s Christmas display and Thanksgiving parades, after all, are classics. Oh, modern holiday strife.
we build websites that make you happy.
get to know us.
Email: hello@silex.co.in Web site: www.silex.co.in
Phone: +91.44.4314.4790
How to Draft Powerful Press Releases For Online Publishing
Press releases can help drive targeted traffic to your website almost instantaneously. But you need to know how to use them correctly. Otherwise, it’s just a waste of time and resources. Here is how you can maximize the results of your press releases.
A good press release, when properly drafted, can help attract the right target audience. Here are some tips on how you can create an effective press release.
Tip 1: Use keyword based headlines for your press releases.
Traditional press releases don’t care about keywords. That is because the releases are meant for the print medium. In a newspaper, a news agent would be more concerned about the news angle.
Press releases on the Internet are quite different. Sure, a headline with a great news angle will help attract more eyeballs. But on the Internet, having a news angle just isn’t enough. Your headlines must contain popular keywords that you know your target visitors will use.
For example, let’s say you want to issue a press release about a new piece of treadmill equipment. This new treadmill has got a new motor that is so quiet that you won’t even notice that it’s running. Unfortunately, the new motor has got a name that nobody knows about (yet). It’s called “kazoom motor”.
Since no one has heard about “kazoom motor” yet, it’s unlikely that they will use these words when searching for information on treadmill motors.
Here are two headline options:
(A) New Kazoom Motor – Quietest Motor in the Market
(B) Quietest Treadmill Motor Tested to Run Silently in Home Treadmills
Which headline do you think is a better headline? Option (B) would be the better headline because your press release will be more likely to show up when visitors use keywords such as “quietest treadmill”, “silent treadmills” or “quiet home treadmills”.
Your primary goal is to attract targeted traffic. You achieve that by using keyword based headlines. If your press release doesn’t show up in the search results for those keywords, it doesn’t matter how you write the press release. Nobody is going to read it.
Tip 2: Use a brief but powerful summary for your press release.
This is of utmost importance – never attempt to write a lengthy summary for your press release. On the Internet, most readers just scan the content. If you have a lengthy summary, you end up chasing away the readers.
The best summary has at most two to three short sentences. Here is the difficult part. Within those two to three sentences, you must sum up what your press release is about. One way to do that is to just focus on one issue.
For instance, your press release body may contain three or four important points. Of those points, pick the most important one and use that as your key message. The job of the summary is simple – to get the key message across. If it fails to accomplish that, you may have just lost a potential customer.
Tip 3: Keep your press release body short.
Sometimes, in the course of my work, I encounter clients asking for lengthy press releases. I try my best to give them what they want, but I also try to give them the correct advice.
My advice to them is that having a lengthy press release may not be the best thing to do. Figures from my web stats software tell me that most visitors spend less than a minute on a web page. In other words, 90% of your readers won’t read the entire press release. You are much better off with a short and concise press release. The ideal word count is about five hundred words, which takes about a minute to read. Anything more than that, your press release is too lengthy.
I know that it’s kind of counterintuitive. After all, how can shorter be better? But it’s true. You want your press releases to be effective. That means you are shooting for measurable results. The results have, time and again, proven that a shorter press release works better.
Five hundred words will allow you to explore just three to four ideas within the press release body. So pick your ideas very carefully. To make sure that you convey your messages clearly, you may wish to employ sub-headers. Bold the sub-headers for a clearer presentation style. When visitors scan your press release, the bold texts will be more likely to catch their attention.
Tip 4: Remember those anchor texts!
A press release can get you valuable back links from many well respected authority sites. These are websites that have been around for years, and many of them have high page rank.
Sure, you may be after the initial traffic rush, which will last for about two weeks or so. But what happens after the initial surge of traffic? Well, you can always rely on organic search traffic.

Like articles, press releases also remain online indefinitely. Since you are allowed to choose your desired anchor texts when you issue paid press releases, why not do some off-site SEO in the process?
Choose your anchor texts wisely and reap the SEO benefits that come with the back links. The links will help boost your search engine rankings. When that happens, you will be receiving organic search traffic. Organic search traffic will become your source of long term traffic.
As you can see, drafting a press release for online publishing can be very different from drafting a release for print publishing. That is because the Internet is a completely different medium, so it requires a very different approach. Keep the above tips in mind and profit from your next press release!
we build websites that make you happy.
get to know us.
Email: hello@silex.co.in Web site: www.silex.co.in
Phone: +91.44.4314.4790
Web Developers Wanted
Location: Chennai (Permanent Resident of Chennai Preferred)
Having secured a wealth of exciting new clients in the past few weeks and months, we’re continually looking to expand our development teams therefore have a need for experienced web developers.
You must have excellent working experience of XHTML, CSS and Javascript as well developing dynamic database driven websites using languages such as PHP and MySQL.
Our ideal candidate is someone who:
- has spent time developing their own personal sites or contributed to open-source projects.
- has a genuine passion for the web and the technologies around it
- is highly motivated, a quick learner and have an attention for detail
- can work well as part of a team
- is always striving to do things better
Salary dependent on experience:
–
By Anitha
What is Google Chrome OS? Video :)
By Anitha
5 Powerful tips to get more exposure!

John Jantsch of Duct Tape Marketing provides five powerful tips about how to get more love from bloggers, tweeters, and fans. My experience is that most companies seeking this love don’t do any of these five things. Ergo, if you did them, you’d be amazed at how well they work.






SocialVibe