JQuery to populate XML into a Table
Hi -
I am trying to create this web page with a table using XML. I know, your not supposed to use tables, unfortunatly the guy here ALWAYS wants tables and says CSS is going to go away and is not supported in all browsers. I won't go there so this is what I have so far and it does not seem to work. Also if you could kind of explain the process so then I can learn and hopefully be able to do this when it is needed again.
Here is my XML (not all of it)...
- <allfaqs>
<FAQs>
<sortNum>1</sortNum>
<question>Q: How do I get a copy of a birth certificate, death certificate or marriage certificate?</question>
<answer>A: These documents are called Vital Records. There is a short application form that you need to complete for the <a target="_blank" href="http://www.racineco.com/crepository/registerofdeeds/birth.pdf">Birth Certificate</a>, <a target="_blank" href="http://www.racineco.com/crepository/registerofdeeds/death.pdf">Death Certificate</a> and <a target="_blank" href="http://www.racineco.com/crepository/registerofdeeds/marriage.pdf">Marriage Certificate</a>. Mail that application form along with a money order (sorry, no personal checks) and a self-addressed, stamped envelope to: Racine County Register of Deeds 730 Wisconsin Ave Racine, WI 53403 or You can submit your request online, with a credit card payment. There are additional fees related to this option, but it offers you the fastest, most convenient service available.</answer>
</FAQs>
<FAQs>
<sortNum>2</sortNum>
<question>Q: Do you provide assistance with my genealogy searches?</question>
<answer>A: Our office is not staffed to perform this type of research. However, it only takes a few minutes to learn how to do this kind of research yourself. If you call ahead, we will be happy to schedule a half-hour orientation session with you. These orientations are done by appointment only, so be sure to call ahead to schedule a time slot.</answer>
</FAQs>
<FAQs>
<sortNum>3</sortNum>
<question>Q: I am considering buying a parcel of real estate. How can I find out what liens, if any, have been filed against it?</question>
<answer>A: If you are borrowing money from a financial institution in order to make the purchase, a title search will be ordered by that financial institution well in advance of the closing. This search will reveal any outstanding liens. If no financial institution is involved, then you will want to contract directly with a title company for a complete title search. In either case, be certain your “Offer to Purchase” contains contingency clauses that state what affect these liens will have on your offer.</answer>
</FAQs>
<FAQs>
<sortNum>4</sortNum>
<question>Q: Can I do my own title search?</question>
<answer>A: Strictly speaking, the answer is “yes”. Practically speaking, however, the answer is probably “no”. The records in the Register of Deeds office are open for public inspection. However, unless you are familiar with how real estate records are organized and how to perform a “Grantor/Grantee” and a “Tract Index” search, it will be easier for you to find the proverbial “needle in a haystack”. Additionally, there may be documents on file with the Clerk of Circuit Court that may impact the property you are interested in. It is our experience that the expertise a professional title searcher offers is well worth the money you will spend – especially when you compare it to the value of the transaction you are about to enter.</answer>
</FAQs></allfaqs>
And here is my HTML
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FAQ</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
</head>
<body>
<div id="container">
<img src="images/LandManagementofDeeds.png" alt="Land Management of Deeds FAQ's" width="500" height="55" />
<table width="1024">
<tr>
<!-- <td valign="top" width="5" align="left"></td>
<td valign="top" width="1019" align="left">-->
<!-- <div id="faqTable"> </div>-->
<script type="text/javascript">
$(document).ready(function () {
var html = '<table id="faqs" cellpadding="0" cellspacing="0">';
$.ajax({
type: "GET",
url: "FAQs.xml",
dataType: "xml",
success: function( xmldata ) {
$(xmldata).find("faqs").each(function () {
html += html + '<tr>' + '<td>'+ ' + $(this).find("question").text()' + '</td> '+ '</tr>' ;
html += html + '<tr>' + '<td>'+ ' + $(this).find("answer").text()' + '</td>' + '</tr>' ;
});
html += html + '</table>';
/*$( "body" ).append( $( html ) );*/
document.getElementById("faqTable").innerHTML = html;
}
});
});
</script>
<!-- </td>-->
</tr>
</table>
</div>
</body>
</html>
I also know you usually use append but he won't let me use that either so I do the getElementById instead.
All I seem to get on the page is the image. I need to understand why I am not getting the rest.
Oh, and it is supposed to be sorted by the sortNum field from the XML.
Any help would be appreciated so I can get this done. Thanks in advance for helping me understand.