Solved

Simple XML/XSL/HTML display

Posted on 2006-06-23
3
245 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now