Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ParseXML

Status
Not open for further replies.

bramble86

Programmer
Nov 26, 2009
3
GB
I have a file named annoucements.php which i am trying to get the contents of announcements.php to appear in my index.php below is the code i have to pull the data from announcements.


<script type="text/javascript">
$(document).ready (function(){
$.ajax({
type:"GET",
url: "announcements.php",
dataType: "xml",
success: parseXml
});
});

function parseXml(xml){
$(xml).find("announcement[current='yes']").each(function()
{
$("#ann").append("<p class='ann_title'>" + $(this).attr('date') + ' ' + $(this).attr('time'));
$("#ann").append("<p class='ann_body'>" + $(this).text());

});
}

</script>


at the end of the file I have another piece of code which i hoped would display the contents. for the purpose of the help i have hard coded some data in

<div id="ann">
<p class="ann_title">21/03/2011 11.35am</p>
<p class="ann_body">Materials for week 9 are now online. Note: A 50 minute video on usability testing will be shown in class on Wednesday which may run past the usual end time of 11.05 pm.</p>
</div><!-- ann -->


How can i get the information to automatically appear in <p class="ann_title"> instead of hard coding it?

Thanks in advance for your help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top