Solved

Simple XML/XSL/HTML display

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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