XML : jquery - render html from xml data file (dynamic column)

Currently using jquery to read xml file of the format shown below, then render an HTML table. HTML table's column headers come from the elements found for each server (in this case: server,a,b,c). Each row is the respective server's values for hostname,a,b,c. The problem is that if the xml's structure is changed, subsequent changes are required on the jquery/js side. Is there a way to get a sample of the elements within the first server element and make those the column headers?

  <servers>      <server hostname="001">          <a>aaa</a>          <b>bbb</b>          <c>ccc</c>      </server>      <server hostname="002">          <a>aaa</a>          <b>bbb</b>          <c>ccc</c>      </server>  </servers>    

No comments:

Post a Comment