XML Namespaces
It is a
collection of element and attributes names associated with an XML vocabulary.
XML Namespaces provide a method to avoid element name conflicts.
XML document 1
<table>
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>
XML document2
<table>
<name>
Coffee Table</name> <width>80</width>
<length>120</length> </table>
If these
XML fragments were added together, there would be a name conflict. Both contain
a <table> element, but the elements have different content and meaning.
Such name conflicts in
XML can easily be avoided using a name prefix as
shown below: <h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African
Coffee Table</f:name> <f:width>80</f:width>
<f:length>120</f:length>
</f:table>
When
using prefixes in XML, a so-called namespace for the prefix must be defined.
The namespace is defined by the xmlns attribute in the start tag of an element.
The namespace declaration has the following syntax.
xmlns:prefix="URI"
For
example,
<h:table
xmlns:h="http://www.w3.org/table"> <h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table
xmlns:f="http://www.w3.org/furniture"> <f:name>African
Coffee Table</f:name> <f:width>80</f:width>
<f:length>120</f:length>
</f:table>
Default namespace
Default
xml namespace uri for elements of a document is
xmlns:http://www.w3.org/1999/xhtml
RSS
RSS stands for Rich Site Summary.
RSS is a format for delivering regularly
changing web content. Many news-related sites and other online publishers
syndicate their content as an RSS Feed to whoever wants it.
RSS
allows you to syndicate your site content.
RSS
defines an easy way to share and view headlines and content.
With RSS
it is possible to distribute up-to-date web content from one web site to
thousands of other web sites around the world.
RSS
allows fast browsing for news and updates. RSS was designed to show selected
data.
Distributing
your content using RSS will involve creating one file that contains your
content.
This file
will reside on your server to enable other web sites to display your channel.
You
can update your channel simply by updating your
file.
Without
RSS, users will have to check your site daily for new updates. This may be too
timeconsuming for many users. With an RSS feed, they can check your site faster
using an RSS aggregator (a site or program that gathers and sorts out RSS
feeds) since RSS data is small and fast-loading
RSS is
useful for web sites that are updated frequently, like:
1. News
sites - Lists news with title, date and descriptions
2. Companies
- Lists news and new products
3. Calendars
- Lists upcoming events and important days
4. Site
changes - Lists changed pages or new pages
RSS files
can be automatically updated
RSS
allows personalized views for different sites
RSS is
written in XML
With RSS
it is possible to distribute up-to-date web content from one web site to
thousands of other web sites around the world.
RSS
allows fast browsing for news and updates. RSS was designed to show selected
data.
Distributing
your content using RSS will involve creating one file that contains your
content.
This file
will reside on your server to enable other web sites to display your channel.
You can update your channel simply by updating your file.
Without
RSS, users will have to check your site daily for new updates. This may be too
time consuming for many users. With an RSS feed, they can check your site
faster using an RSS aggregator (a site or program that gathers and sorts out
RSS feeds) since RSS data is small and fast-loading
RSS is
useful for web sites that are updated frequently, like:
1. News
sites - Lists news with title, date and descriptions
2. Companies
- Lists news and new products
3. Calendars
- Lists upcoming events and important days
4. Site
changes - Lists changed pages or new pages
Creating
an RSS File
Your
first step will be to identify your file. To do this, place the following code
at the top of your text file.
<?xml
version="1.0"?> <rss version="0.91">
Your next
step will be to create your channel header. The "channel" tag
indicates that you are beginning a new channel.
<channel>
<title>Web-Source.net
Syndication</title> <link>http://www.web-source.net</link>
<description>Web
Development article syndication feeds!</description>
<language>en-us</language>
The
"title" tag indicates the name of your channel. The "link"
tag will contain a link to your website. The "description" tag
describes your channel and the "language" tag indicates that you're
writing in US English.
<item>
<title>
Creating A Customized Marquee </title>
<link>http://www.example.com/tips.htm</link> <description>
Learn how
to create a customized marquee for your web </description>
</item>
Your
final step will be to close your channel by adding the following tags:
</channel>
</rss>
Save your
new file with .rss file extension and upload it to your server. And now, you're
ready to share your content.
JavaScript and XML: AJAX
AJAX:
- AJAX
stands for Asynchronous JavaScript and XML
- AJAX
allows web pages to be updated asynchronously by exchanging small amounts of
data with the server behind the scenes. This means that it is possible to
update parts of a web page, without reloading the whole page.
- Using
Ajax,
o Update
a web page with new data without reloading the page o Request data from a
server after the page has loaded
o Receive
data from a server after the page has loaded o Send data to a server in the
background
- AJAX
allows updating parts of a web page, without reloading the whole page.
- With
Ajax, web applications can also retrieve data from the server asynchronously in
the background without interfering with the display and behavior of the
existing page.
- Ajax is
combination of
o HTML o
XML o CSS
o
JavaScript
o
JavaScript DOM
o
XMLHttpRequest in asynchronous mode.
1.
Asynchronous:
This
means that when you send a request, you wait for the response to come back, but are free to do other
things while you wait. The response probably won’t come back immediately, so
you set up a function that will wait for the response to be sent back by the
server, and react to it once that happens.
2.
JavaScript
JavaScript
is used to make a request to the server. Once the response is returned by the server, you will
generally use some more JavaScript to modify the current page’s document object
model in some way to show the user that the submission went through
successfully.
3.
XML The data
that you receive back from the server will often be packaged up as a snippet of XML, so that it can be
easily processed with JavaScript. This data can be anything you want, and as
long as you want.
How AJAX
works?
XMLHttpRequest
- Constructor for other host objects allow a JavaScript program to send
an
HTTP
request to a server and receive back a response containing an XML document. The
following program illustrates the use of XMLHttpRequest.
Example <html> <head>
<script
type="text/javascript"> function dataData()
{
var xmlhttp=new XMLHttpRequest(); // create XMLHttpRequest to exchange
data with server
var obj=
getElementById("myDiv"); xmlhttp.onreadystatechange=function()
{
if
(xmlhttp.readyState==4 && xmlhttp.status==200)
{
obj=xmlhttp.responseText;
}
}
xmlhttp.open("GET",”data.txt”,
true); xmlhttp.send();
}
</script>
</head>
<body><form>
<div
id="myDiv">Let AJAX change this text</div>
<input
type="button" value=”Change Content” onclick=”getData()”; />
</form></body>
</html>
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.