2

this is my code:-

var xml = "<results><result><Country_Code>IN</Country_Code><Country_Name>India</Country_Name><Region_Name>Gujarat</Region_Name><City>Rajkot</City><lat>13.060422</lat><lng>80.24958300000003</lng></result><result><Country_Code>KE</Country_Code><Country_Name>Kenya</Country_Name><Region_Name>Vihiga</Region_Name><City>Kakamega</City><lat>0.1182473</lat><lng>34.7334515999997</lng></result></results>";


xmlDoc = $.parseXML( xml );
$xml = $( xmlDoc );
function get_list(ls){
   $lat = $("#select").val();
   $lng = $("#value").val();
   $title = $xml.find( "lat:contains('"+$lat+"')" ).closest('result');    
   $t = $title.find("lng:contains('"+$lng+"')").closest('result');    
   $str = $t.contents().map(function(){
       return $(this).contents().eq(0).text();
   }).get().join(' ');

   $("#result").text($str);
}

i want to set my output in table structure like:-

<table>
<td>Country_Code: </td><td>IN</td><td><tr>
<td>Country_Name: </td><td>India</td><td><tr>
<td>Region_Name: </td><td>Gujarat</td><td><tr>
<td>City: </td><td>Rajkot</td><td><tr>
<td>lat: </td><td>13.060422</td><td><tr>
<td>lng: </td><td>80.24958300000003</td><td><tr>
</table>

as above i want to set my output as a table wise Please help me how to do this...
thanks...

1
  • Why dont you use some templating library? Commented Mar 21, 2013 at 13:44

1 Answer 1

1

In side the function u create the table and stored in one variable and append the variable where u want it.this is only example..

var table = '<table><tr><td>'+$title>+'</td><td>'+$t+'</td></tr></table>';

and append the table in one div

$("#divid").append(table);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.