Reputation: 723
I am a new in webdevelopment and i want to parse xml from webserver not from local server how is it possible .I tried lots of googled.Please help me .I have to parse this url "http://twitter.com/statuses/public_timeline.xml"
Upvotes: 4
Views: 3607
Reputation: 5835
You can use JQuery (http://jquery.com/) plugin in HTML page as entry in a script tag, called jquery's ajax() function to hit the url and u can use jquery's parseXML() and find() function to parse xml data like this-
<html>
<head>
<script src="js/jquery-1.4.2.js" type="text/javascript" charset="utf-8"></script>
<script>
function onBodyLoad(){
$.ajax({
url:'http://twitter.com/statuses/public_timeline.xml',
dataType:"xml",
contentType:'application/xml',
timeout:10000,
type:'POST',
success:function(data) {
alert(data);
var xmlDoc = $.parseXML( data ),
$xml = $( xmlDoc ),
$title = $xml.find( "title" );
/* append "RSS Title" to #someElement */
$( "#someElement" ).append( $title.text() );
/* change the title to "XML Title" */
$title.text( "XML Title" );
/* append "XML Title" to #anotherElement */
$( "#anotherElement" ).append( $title.text() );
},
error:function(XMLHttpRequest,textStatus, errorThrown) {
alert("Error status :"+textStatus);
alert("Error type :"+errorThrown);
alert("Error message :"+XMLHttpRequest.responseXML);
}});
}
</script>
</head>
<body onload="onBodyLoad()">
<p id="someElement"></p>
<p id="anotherElement"></p>
</body>
</html>
Upvotes: 3
Reputation: 1185
This is called syndication feed
http://dotnetslackers.com/articles/aspnet/How-to-create-a-syndication-feed-for-your-website.aspx
you can take help from above url, and can use ASP.NET wrapper for Twitter API as well
Upvotes: -2