开发者

Refreshing the xml file through button

开发者 https://www.devze.com 2023-04-05 04:25 出处:网络
I am using an asp web application that has a tab. When I click on that tab, an xml file is read. That xml file has data in it. That xml file has a href pointing to an xslt file where I have written co

I am using an asp web application that has a tab. When I click on that tab, an xml file is read. That xml file has data in it. That xml file has a href pointing to an xslt file where I have written code for creating a table for displaying the xml data in the xml file in a presentable manner in the browser.

The user may change the data in the xml file or he may remove some data too, during runtime. I have included a refresh button in the xslt file. During runtime, if the user makes changes to the xml file, I wish to click on the refresh button to reflect the changes in the table in web page. I just want the xml file to be refreshed and the corresponding changes to be reflected in the web page.

How do I do this? I have uploaded my code below :

ASPX FILE

<%@ Page Title="Home Page" Language="C#"  AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="sampleapp._Default" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<html>
<head id="Head1" runat="server">
<meta http-equiv="Cache-Control" content="no-cache"/>
        <meta http-equiv="Pragma" content="no-cache"/>
        <meta http-equiv="Expires" content="0"/>

        <title>VPGate Configuration</title>
        <link rel="stylesheet" type="text/css" href="office2007.css"/>
        <link rel="stylesheet" type="text/css" href="style002.css"/>
         <script language="javascript" type="text/javascript">
             function window.onload() {
                 try {
                     if (self != top)
                         self.parent.location = document.location;

                 }
                 catch (Exception) { }
             }
        </script>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
 <script type="text/javascript">
     function OnClientTabSelected(sender, eventArgs) {
         var tab = eventArgs.get_tab();
         if (tab.get_tabs().get_count() > 0) {
             tab.get_tabs().getTab(0).select();
             //tab.get_tabs().getTab(0).click();
         }
         if (tab.get_text() == "Help") {
             document.getElementById("helpframe").style.display = "inline";
             document.getElementById("framebody").style.display = "none";
             document.getElementById("framebody").src = "";
             if (document.getElementById("helpframe").src == "")
                 document.getElementById("helpframe").src = "/help/ApplicationHelp.htm";
         }
         else {
             document.getElementById("helpframe").style.display = "none";
             document.getElementById("framebody").style.display = "inline";
         }
     }
     function OnClientTabSelecting(sender, eventArgs) {
         if (!formchk2()) {
             eventArgs.set_cancel(true);
             return false;
         }
     }
    </script>
 <telerik:RadTabStrip ID="tab1" runat="server" ShowBaseLine="True" 
            EnableEmbeddedSkins="False" ClickSelectedTab="True" 
            UnSelectChildren="True" SelectedIndex="3" 
            OnClientTabSelected="OnClientTabSelected" Skin="Office2007" style="margin-left: 29px;border-left-style:none;"
    OnClientTabSelecting="OnClientTabSelecting">
    <Tabs>
     <telerik:RadTab Text="General" NavigateUrl="ShowXML.aspx?file=MMDiagnostics.xml" Target="framebody" Selected="true"></telerik:RadTab>
    </Tabs>
      </telerik:RadTabStrip>
     <iframe id="framebody" name="framebody"   runat="server"
            style="border-left: thin solid #4173be; border-right: thin solid #4173be; border-bottom: thin solid #4173be; height:112%; width:100%; border-top-width:0px; border-top-color:White; 
             background-color:white; float:left;height:92.5%; width:97.4%; margin-left:9.5px;" 
            frameborder="0" scrolling="no">
    </iframe>
      </form>
      </body>
</html>

XML FILE

<?xml-stylesheet type="text/xsl" href="MMDiagnostics.xslt"?>

<MediaMixer>

  <Conference>
    <Name>Test001</Name>
    <ConfId>1000</ConfId>
    <CompositeAddress>238.57.0.1</CompositeAddress>
    <CompositePort>48000</CompositePort>
    <CompositeSsrc>243324353</CompositeSsrc>
    <NoOfParticipants>2</NoOfParticipants>

    <Participant>
      <ID1>80542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.40</ParticipantAddress>
      <ParticipantListeningPort>22000</ParticipantListeningPort>
      <MMListeningPort>45000</MMListeningPort>
      <SSRCFromParticipant>216541</SSRCFromParticipant>
      <SSRCFromMM>56481</SSRCFromMM>
    </Participant>

    <Participant>
      <ID1>80542151</ID1>
      <ID2>harish</ID2>
      <ParticipantAddress>192.168.177.40</ParticipantAddress>
      <ParticipantListeningPort>22000</ParticipantListeningPort>
      <MMListeningPort>45000</MMListeningPort>
      <SSRCFromParticipant>216541</SSRCFromParticipant>
      <SSRCFromMM>56481</SSRCFromMM>
    </Participant>

    <Participant>
      <ID1>7825482</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.22</ParticipantAddress>
      <ParticipantListeningPort>22002</ParticipantListeningPort>
      <MMListeningPort>45002</MMListeningPort>
      <SSRCFromParticipant>3256</SSRCFromParticipant>
      <SSRCFromMM>14822456</SSRCFromMM>
    </Participant>

  </Conference>

  <Conference>
    <Name>Test002</Name>
    <ConfId>1002</ConfId>
    <CompositeAddress>238.57.0.1</CompositeAddress>
    <CompositePort>48005</CompositePort>
    <CompositeSsrc>353324353</CompositeSsrc>
    <NoOfParticipants>2</NoOfParticipants>

    <Participant>
      <ID1>70542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>
    <Participant>
      <ID1>70542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>
    <Participant>
      <ID1>70542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>
    <Participant>
      <ID1>70542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>
    <Participant>
      <ID1>70542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>

    <Participant>
      <ID1>5625482</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.20</ParticipantAddress>
      <ParticipantListeningPort>22006</ParticipantListeningPort>
      <MMListeningPort>45006</MMListeningPort>
      <SSRCFromParticipant>8256</SSRCFromParticipant>
      <SSRCFromMM>41822456</SSRCFromMM>
    </Participant>

  </Conference>

</MediaMixer>

XSLT FILE

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">

    <html>
      <head>
        <title>VPGate Media Mixer</title>

        <meta http-equiv="expires" content="0"/>
        <meta http-equiv="pragma" content="no-cache"/>
        <meta http-equiv="cache-control" content="no-cache, must-revalidate"/>
        <meta http-equiv="refresh" content="15"></meta>
        <script src="/Common/common.js\" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="style001.css" />
        <link rel="stylesheet" type="text/css" href="Grid.Default.css" />


      </head>

      <body class="WorkArea">       
        <div class="divSummaryHeader" id="SummaryHeader">
          <h1>Media Mixer - VPGate</h1>

          <xsl:for-each select="MMDiagnostics/Conference">
            <h1>
              Media Mixer - <xsl:value-of select="name"/>
            </h1>
          </xsl:for-each>
        </div>

        &#160;



        <div class="RadGrid RadGrid_Default" id="SummaryData" style="position:absolute;width:630px;overflow:auto">

          <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
            <tr>
              <input type="button" class="formEditBtn" id="SubBtn" value="Refresh" onclick="window.location=window.location;"/>

              </tr>
              <tr>
                <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Conference</td>
              </tr>

              <tr>
                <td>
                  <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
                    <tr>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Name</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Id</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Address</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Port</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Ssrc</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">No Of Participants</td>
                    </tr>

                    <xsl:for-each select="MediaMixer/Conference">
                      <!--<xsl:sort select="Name"/>-->
                      <xsl:if test="(position() mod 2 = 0)">

                        <tr class="rgAltRow SummaryTableDataRow">
                          <td valign = "top">
                            <xsl:value-of select="Name"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ConfId"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="CompositeAddress"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="CompositePort"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="CompositeSsrc"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="NoOfParticipants"/>
                          </td>
                   开发者_JAVA技巧     </tr>
                      </xsl:if>

                      <xsl:if test="(position() mod 2 = 1)">
                        <td bgcolor="#aaaaff">
                          <tr class="rgAltRow SummaryTableDataRow">
                            <td valign = "top">
                              <xsl:value-of select="Name"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ConfId"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositeAddress"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositePort"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositeSsrc"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="NoOfParticipants"/>
                            </td>
                          </tr>
                        </td>
                      </xsl:if>

                    </xsl:for-each>

                  </table>
                </td>
              </tr>
            </table>

            &#160;

            <table border="0" class="rgMasterTable rgClipCells" cellspacing="1" cellpadding="1" >
              <tr>
                <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Participant</td>
              </tr>

              <tr>
                <td>

                  <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
                    <tr>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">ID 1</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">ID 2</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Address</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Listening Port</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">MM Listening Port</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From Participant</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From MM</td>
                    </tr>

                    <xsl:for-each select="MediaMixer/Conference/Participant">

                      <xsl:if test="(position() mod 2 = 0)">

                        <tr class="rgAltRow SummaryTableDataRow">
                          <td valign = "top">
                            <xsl:value-of select="ID1"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ID2"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ParticipantAddress"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ParticipantListeningPort"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="MMListeningPort"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="SSRCFromParticipant"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="SSRCFromMM"/>
                          </td>
                        </tr>
                      </xsl:if>

                      <xsl:if test="(position() mod 2 = 1)">
                        <td bgcolor="#aaaaff">
                          <tr class="rgAltRow SummaryTableDataRow">
                            <td valign = "top">
                              <xsl:value-of select="ID1"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ID2"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ParticipantAddress"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ParticipantListeningPort"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="MMListeningPort"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="SSRCFromParticipant"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="SSRCFromMM"/>
                            </td>

                          </tr>
                        </td>
                      </xsl:if>
                    </xsl:for-each>

                  </table>
                </td>
              </tr>
            </table>


            &#160;


            <div style="display:none">
              <iframe id="frameUpdate" name="frameUpdate" width="100%"></iframe>
            </div>


          </div>

          </body> 
    </html>
    </xsl:template>
</xsl:stylesheet>


You can set at the client side timer using setTimeout function. Eeach time you can read the xml and check modified date of the file. Or for example to set attribute in XML changedDate and to check it each time.If it's changed from previous one you can refresh the xml .


So as I stated previously you can check modified data of xml or to set attribute "ModifiedDate" in XML . When someone updates XML , he must change update the attribure.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号