?
Solved

Simple XML/XSL/HTML display

Posted on 2006-06-23
3
Medium Priority
?
266 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 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

771 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