<!DOCTYPE html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var html="";
$.ajax({
type: "GET",
url: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22www.vegvesen.no%2Ftrafikk%2Fxml%2Fsavedsearch.xml%3Fid%3D600%22&format=json&diagnostics=true",
dataType: "jsonp"
}).done(function(trafikk) {
$(trafikk.query.results.searchresult['result-array'].result.messages.message).each(function(index, item) {
html+='<div class="result">';
html+='<div class="fylke">'+item.actualCounties.string+'</div>';
html+='<div class="heading">'+item.heading+'</div>';
html+='<div class="ingress">'+item.ingress+'</div>';
html+='<div class="msg_type">'+item.messageType+'</div>';
html+='<div class="veitype">Vei : '+item.roadType+''+item.roadNumber+'</div>';
html+='<div class="viktighet">Viktighet : '+item.urgency+'</div>';
html+='<div class="gyldig">Gyldig fra : '+item.validFrom+'</div>';
html+='</div><br /><br />';
console.log(item); //midlertidig, lar deg se json objektet i konsollen
});
$("#vegvesen").html(html);
}).fail(function() {
console.log('feil');
//lag en feilmelding her dersom dataene ikke kan vises
});
});
</script>
</head>
<body>
<div id="vegvesen"></div>
</body>
</html>