Best way to refresh this table on-the-fly
I have some simple XML like this:
<Tag>
<Keyphrases>
<Keyphrase Phrase = "This is phrase one"/>
<Keyphrase Phrase = "This is phrase two"/>
<Keyphrase Phrase = "This is phrase three"/>
</Keyphrases>
</Tag>
And I have an XSLT that contains:
[...]
<table id="realtimetable">
<xsl:apply-templates select="Tag/Keyphrases"/>
</table>
[...]
<!-- Build KeyPhrase Rows -->
<xsl:template match="Tag/Keyphrases">
<xsl:for-each select="Keyphrase">
<tr><td>
<xsl:value-of select="@Phrase" />
</td></tr>
</xsl:for-each>
</xsl:template>
But now I wish to update the content of that table on the fly. I understand I can use XMLHttpRequest() to fetch new data.
However, I do not know what format to use for those updates or how to insert the new data into the table.
I can supply the updates in XML. But can I re-use my existing XSLT template to parse it and repopulate the displayed table? This seems elegant and tidy but is it possible and if so, how would I do it?
If that's not possible, I suppose I could write the Javascript to parse the XML and update the table myself. That sounds like a lot of grunt work :-(
So I was also considering responding to the XMLHTTPRequest in JSON format. I think it may be easier to process JSON that it is to parse the XML.
But what should my JSON document look like and how do I write the JavaScript to process the JSON and repopulate the table?
Asumming I have a clean (error checked) response from XMLHttpRequest() what do I do here?
function ProcessUpdate()
{
}
I would prefer to avoid using any libraries such as jQuery for this project.