use of li text and xml

by andrew rowe

HTML

<script type="text/xml" id="xmlData">
<companies>
    <company name="1" imageurl="logo">
    <certification> Certified Best Employer </certification>
    <employee> 5,0000 </employee>
    <industry> Risk Services </industry>
    <html_url> http://www.google.com </html_url>
    </company>

    <company name="2" imageurl="logo">
    <certification> Certified Best Employer </certification>
    <employee> 5,0000 </employee>
    <industry> Legal Services </industry>
    <html_url> http://www.google.com </html_url>
    </company>

    <company name="3" imageurl="logo">
    <certification> Certified Best Employer </certification>
    <employee> 5,0000 </employee>
    <industry> Health Services </industry>
    <html_url> http://www.google.com </html_url>
    </company>
</companies>
</script>

<ul id="output"></ul>

JavaScript

var xmlText = $('#xmlData').text();
var $xmlData = $.parseXML(xmlText)

$('company', $xmlData).each(function(index, company) {
    $('#output').append($('<li>').text($('industry', company).text()))
});