Web Analytics Made Easy -
StatCounter Transform XML to ANother format - CodingForum

Announcement

Collapse
No announcement yet.

Transform XML to ANother format

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transform XML to ANother format

    Greetings,

    I am not a programmer, so when I encounter the type of problem that I will expose, I am ever so grateful :-)

    I have a report per machine and the report can only be saved in XML.

    I would like to now convert the report in whatever, HTML, DOC, PDF, spreadsheet etc. The issue is that I need to be able to exploit it.

    I have posted the report on my site:

    http://www.cisware.co.uk/xmlproblem it’s only 20 K

    Anybody could give me a tool to just convert this thing? I am fluent in English/French….

    Best wishes,
    Jimmy

  • #2
    Copy and paste to [viewer.htm] and put in same directory as your xml file.
    And run with IE.

    Code:
    <html>
      <head>
        <script>
          onload = function() {
            document.body.innerHTML = xml.transformNode(xsl);
          }
        </script>
        <style>
          *     {cursor:default;}
          td    {font:8pt tahoma;}
          .even {background:#f6f6f6;}
          .odd  {background:#eee;}
          .child-6,.child-7,.child-8 {color:blue;text-align:right;}
        </style>
        <xml id="xml" src="ptpierrea4.xml"/>
        <xml id="xsl">
          <?xml version="1.0"?>
          <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:template match="/">
              <table>
                <thead>
                  <xsl:for-each select="//Table1[1]/node()">
                    <th><xsl:value-of select="local-name()"/></th>
                  </xsl:for-each>
                </thead>
                <tbody>
                  <xsl:apply-templates />
                </tbody>
              </table>
            </xsl:template>
            <xsl:template match="Table1">
              <xsl:variable name="class">
                <xsl:choose>
                  <xsl:when test="position() mod 2 = 1">even</xsl:when>
                  <xsl:otherwise>odd</xsl:otherwise>
                </xsl:choose>
              </xsl:variable>
              <tr class="{$class}">
                <xsl:for-each select="node()">
                  <td class="child-{position()}">
                    <xsl:value-of select="text()"/>
                  </td>
                </xsl:for-each>
              </tr>
            </xsl:template>
            <xsl:template match="text()" />
          </xsl:stylesheet>
        </xml>
      </head>
      <body>
      </body>
    </html>

    Comment

    Working...
    X