https://www.freeformatter.com/xsl-transformer.html
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/Log">
<html>
<body>
<xsl:for-each select="Message">
<div style="background-color: #cce6ff; border-radius: 1em; margin: 2em; padding: 1em">
<p><strong>From:</strong> <xsl:value-of select="From/User/@FriendlyName"/> </p>
<p><strong>To:</strong> <xsl:value-of select="To/User/@FriendlyName"/> </p>
<xsl:value-of select="Text"/>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
import sys
from xml.dom.minidom import parse
if len(sys.argv) != 2:
print >>sys.stderr, "usage: " + sys.argv[0] + " <inputfile>"
sys.exit(1)
doml = parse(sys.argv[1])
for message in doml.getElementsByTagName("Message"):
fromNode = message.getElementsByTagName("From")[0]
userNode = fromNode.getElementsByTagName("User")[0]
name = "At " + message.getAttribute("Date") + ", " + message.getAttribute("Time") + ", " + userNode.getAttribute("FriendlyName") + \
" says:"
print name.encode('utf-8')
msg = message.getElementsByTagName("Text")[0].firstChild.nodeValue
print msg.encode('utf-8')
print ""
cd Desktop
python script.py chat_log.xml
python script.py chat_log.xml > chat_log_out.txt
Hello, I tried but Terminal shows that:Okay, let's use the script. I've edited it a bit to show the date. This is it now:
Take the script, and Cmd+C copy it. Then open TextEdit and Cmd+V paste it. Don't change anything. Save the file as "script.py", without the quotes, to your Desktop. Then move your xml logs to the Desktop, too, to make things simple.Code:import sys from xml.dom.minidom import parse if len(sys.argv) != 2: print >>sys.stderr, "usage: " + sys.argv[0] + " <inputfile>" sys.exit(1) doml = parse(sys.argv[1]) for message in doml.getElementsByTagName("Message"): fromNode = message.getElementsByTagName("From")[0] userNode = fromNode.getElementsByTagName("User")[0] name = "At " + message.getAttribute("Date") + ", " + message.getAttribute("Time") + ", " + userNode.getAttribute("FriendlyName") + \ " says:" print name.encode('utf-8') msg = message.getElementsByTagName("Text")[0].firstChild.nodeValue print msg.encode('utf-8') print ""
Now, the script is written in the Python programming language, that comes preinstalled with macOS, so it should run just fine.
Open Terminal. Your working directory is now your home dir. Your Desktop is right inside it so just write
and hit return (enter).Code:cd Desktop
Python scripts are run with this syntax: python file +arguments
The name of the file to be run is script.py and your only argument is the name of the log file. I don't know the name of your log files, so I'll just pretend one of them is called chat_log.xml
Type
then hit return (enter).Code:python script.py chat_log.xml
The script should print the conversation directly to your terminal. If you want to put it into a file, just change the command like this:
View attachment 753595Code:python script.py chat_log.xml > chat_log_out.txt
Hello, I tried but Terminal shows that:
File "script.py", line 1
{\rtf1\ansi\ansicpg950\cocoartf1671\cocoasubrtf100
^
SyntaxError: unexpected character after line continuation character
Thank you very much!!You must have saved that file as RTF (rich text format), not as TXT (plaintext), which is not your fault, as that's what TextEdit does by default.
When you're about to save the script in TextEdit, make sure it's in the plaintext mode — in the bar at the top of the screen click Format, then Convert to plaintext (roughly, my OS is in Czech).
The TextEdit window is supposed to look like this:
View attachment 808074
NOT like this:
View attachment 808075
After you do that, save the file as script.py (DO NOT forget the .py extension) and proceed.
Okay, let's use the script. I've edited it a bit to show the date. This is it now:
Take the script, and Cmd+C copy it. Then open TextEdit and Cmd+V paste it. Don't change anything. Save the file as "script.py", without the quotes, to your Desktop. Then move your xml logs to the Desktop, too, to make things simple.Code:import sys from xml.dom.minidom import parse if len(sys.argv) != 2: print >>sys.stderr, "usage: " + sys.argv[0] + " <inputfile>" sys.exit(1) doml = parse(sys.argv[1]) for message in doml.getElementsByTagName("Message"): fromNode = message.getElementsByTagName("From")[0] userNode = fromNode.getElementsByTagName("User")[0] name = "At " + message.getAttribute("Date") + ", " + message.getAttribute("Time") + ", " + userNode.getAttribute("FriendlyName") + \ " says:" print name.encode('utf-8') msg = message.getElementsByTagName("Text")[0].firstChild.nodeValue print msg.encode('utf-8') print ""
Now, the script is written in the Python programming language, that comes preinstalled with macOS, so it should run just fine.
Open Terminal. Your working directory is now your home dir. Your Desktop is right inside it so just write
and hit return (enter).Code:cd Desktop
Python scripts are run with this syntax: python file +arguments
The name of the file to be run is script.py and your only argument is the name of the log file. I don't know the name of your log files, so I'll just pretend one of them is called chat_log.xml
Type
then hit return (enter).Code:python script.py chat_log.xml
The script should print the conversation directly to your terminal. If you want to put it into a file, just change the command like this:
View attachment 753595Code:python script.py chat_log.xml > chat_log_out.txt
Hi!
I did try to use the 'python script.py logfile.xml' in a different OS and then it returned:
...
Does this script works only in macOS?
BTW, Python 3.7.2 version.
Thanks!
Okay, let's use the script. I've edited it a bit to show the date. This is it now:
Take the script, and Cmd+C copy it. Then open TextEdit and Cmd+V paste it. Don't change anything. Save the file as "script.py", without the quotes, to your Desktop. Then move your xml logs to the Desktop, too, to make things simple.Code:import sys from xml.dom.minidom import parse if len(sys.argv) != 2: print >>sys.stderr, "usage: " + sys.argv[0] + " <inputfile>" sys.exit(1) doml = parse(sys.argv[1]) for message in doml.getElementsByTagName("Message"): fromNode = message.getElementsByTagName("From")[0] userNode = fromNode.getElementsByTagName("User")[0] name = "At " + message.getAttribute("Date") + ", " + message.getAttribute("Time") + ", " + userNode.getAttribute("FriendlyName") + \ " says:" print name.encode('utf-8') msg = message.getElementsByTagName("Text")[0].firstChild.nodeValue print msg.encode('utf-8') print ""
Now, the script is written in the Python programming language, that comes preinstalled with macOS, so it should run just fine.
Open Terminal. Your working directory is now your home dir. Your Desktop is right inside it so just write
and hit return (enter).Code:cd Desktop
Python scripts are run with this syntax: python file +arguments
The name of the file to be run is script.py and your only argument is the name of the log file. I don't know the name of your log files, so I'll just pretend one of them is called chat_log.xml
Type
then hit return (enter).Code:python script.py chat_log.xml
The script should print the conversation directly to your terminal. If you want to put it into a file, just change the command like this:
View attachment 753595Code:python script.py chat_log.xml > chat_log_out.txt