I am writing a basic xslt program. I cannot get to select the nodes i want. I am targetting to see /Events/Event/System/Computer
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h2>Event</h2>
<table>
<tr>
<xsl:apply-templates/>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Event">
<td><xsl:apply-templates select="System"/> </td>
</xsl:template>
<xsl:template match="System">
<xsl:apply-templates select="Computer"/>
</xsl:template>
<xsl:template match="Computer">
Computer: <span style="color:#ff0000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>
Above is my style sheet, I am trying to print computer value on a loop. In my example XML below, what is required is to print the computer name twice.
XML code
---------
`<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Events>
<Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'>
<System>
<Provider Name='Application Error'/>
<EventID Qualifiers='0'>1000</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>100</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime='2023-01-11T10:22:54.9821986Z'/>
<EventRecordID>85280</EventRecordID>
<Correlation/>
<Execution ProcessID='0' ThreadID='0'/>
<Channel>Application</Channel>
<Computer>Peru-Desktop</Computer>
<Security/>
</System>
<EventData>
<Data>RuntimeBroker.exe</Data>
<Data>10.0.19041.746</Data>
<Data>5b78739c</Data>
<Data>ntdll.dll</Data>
<Data>10.0.19041.2130</Data>
<Data>b5ced1c6</Data>
<Data>c0000374</Data>
<Data>00000000000ff6a9</Data>
<Data>28c0</Data>
<Data>01d9259e77eefd6c</Data>
<Data>C:\Windows\System32\RuntimeBroker.exe</Data>
<Data>C:\Windows\SYSTEM32\ntdll.dll</Data>
<Data>66a01ef8-5dc9-4305-8670-d39ef7144aaf</Data>
<Data>Microsoft.Windows.Search_1.14.7.19041_neutral_neutral_cw5n1h2txyewy</Data>
<Data>runtimebroker07f4358a809ac99a64a67c1</Data>
</EventData>
</Event>
<Event
xmlns='http://schemas.microsoft.com/win/2004/08/events/event'>
<System>
<Provider Name='Application Error'/>
<EventID Qualifiers='0'>1000</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>100</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime='2023-01-11T05:17:35.3925442Z'/>
<EventRecordID>85258</EventRecordID>
<Correlation/>
<Execution ProcessID='0' ThreadID='0'/>
<Channel>Application</Channel>
<Computer>Peru-Desktop</Computer>
<Security/>
</System>
<EventData>
<Data>ftnlsv.exe</Data>
<Data>3.3.10.0</Data>
<Data>5fa14984</Data>
<Data>ntdll.dll</Data>
<Data>10.0.19041.2130</Data>
<Data>b5ced1c6</Data>
<Data>c0000409</Data>
<Data>000000000008c67f</Data>
<Data>15bc</Data>
<Data>01d925799d1bd691</Data>
<Data>C:\Program Files\Common Files\VMware\DeviceRedirectionCommon\ftnlsv.exe</Data>
<Data>C:\Windows\SYSTEM32\ntdll.dll</Data>
<Data>96b01680-a7d7-4e54-b2a8-b350ed24498d</Data>
<Data></Data>
<Data></Data>
</EventData>
</Event>
</Events>`
Currently I print everything including and all values under Event, This is not what i was wondering.
`<!DOCTYPE html>
<html>
<body>
<h2>Event</h2>
<table>
<tr><td>Computer: <span style="color:#ff0000">Peru-Desktop</span><br /></td></tr>
<tr><td>Computer: <span style="color:#ff0000">Peru-Desktop</span><br /></td></tr>
</table></body></html>`