Solved

Simple XML/XSL/HTML display

Posted on 2006-06-23
3
254 Views
Last Modified: 2010-05-18
Hi, I have a error log file which comes in XML, something like:

<?xml version="1.0" encoding="UTF-8"?>
    <response requestHandle="4144037/1*174*2" requestType="add">
        <ack>successful</ack>
    </response>
    <response requestHandle="3555219/2*12*1" requestType="add">
        <error>Error messages
 &lt;itemHandle handle="CL18" type="nonInventorySaleItem"/&gt;
</error>
    </response>
    <response requestHandle="216039/3*29*1" requestType="add">
        <ack>successful</ack>
    </response>
    <response requestHandle="3334017/12*1*1" requestType="add">
        <ack>successful</ack>
    </response>
<response requestHandle="3555219/2*12*1" requestType="add">
        <error>Error messages
 &lt;itemHandle handle="CL18" type="nonInventorySaleItem"/&gt;
</error>
    </response>

I just want to be able to create some XSL that will be able to display the error messages, requestHandle, itemHandle, and type etc just in HTML table?


Anyone know how?
0
Comment
Question by:gaz1000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
jkmyoung earned 100 total points
ID: 16969304
First off, in order for xslt to process your xml, you're only allowed one element at the root level.
So, you'd have to encompass all of your xml inside of an element eg, like
<root>
  <response> blah.. </response>
  <response> etc.. etc.
...
</root>

Looks like you're looking for something like:
<table>
  <tr><!-- put your header row data here,.  --></tr>

  <xsl:for-each select="/root/response[error]"/> <!-- select all responses which have an error -->
    <tr>
      <td><xsl:value-of select="error" /></td>
      <td><xsl:value-of select="@requestHandle" /></td>
      <td><xsl:value-of select="substring-before(substring-after(error, 'handle=&quot;), '&quot;')" /></td>
      <td><xsl:value-of select="@requestType" /></td>
    </tr>
  </xsl:for-each>
</table>

0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Removing information on Duplicate XML Nodes 24 83
Extract XML Data from using TSQL 5 69
XML XSL Choose example 3 38
Help needed with Powershell  XML to MySQL 5 73
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question