Skip to content

Instantly share code, notes, and snippets.

@farcaller
Created February 17, 2009 11:20
Show Gist options
  • Save farcaller/65697 to your computer and use it in GitHub Desktop.
Save farcaller/65697 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8" ?>
<!--
This awful thing parses vkontakte.ru/mail.php
I am *NOT* proud of it. C'est la vie.
Created by Farcaller on 2009-02-17.
Copyright (c) 2009 Hack&Dev FSO. All rights reserved.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xhtml">
<xsl:output encoding="UTF-8" indent="yes" method="xml" />
<xsl:template match="/">
<plist version="1.0">
<array>
<xsl:for-each select="//xhtml:div[@class='mailbox']/xhtml:table/xhtml:tr">
<xsl:if test="position() &gt; 1">
<xsl:apply-templates select="."/>
</xsl:if>
</xsl:for-each>
</array>
</plist>
</xsl:template>
<xsl:template match="xhtml:tr">
<dict>
<key><xsl:text>avatar</xsl:text></key>
<string><xsl:value-of select="xhtml:td[@class='messagePicture']/xhtml:a/xhtml:img/@src"/></string>
<key><xsl:text>from_name</xsl:text></key>
<string><xsl:value-of select="xhtml:td[@class='messageFrom']/xhtml:div[@class='name']/xhtml:a"/></string>
<key><xsl:text>from_id</xsl:text></key>
<string><xsl:value-of select="xhtml:td[@class='messageFrom']/xhtml:div[@class='name']/xhtml:a/@href"/></string>
<key><xsl:text>date</xsl:text></key>
<string><xsl:value-of select="xhtml:td[@class='messageFrom']/xhtml:div[@class='date']"/></string>
<xsl:for-each select="xhtml:td[@class='messageSnippet']/xhtml:div/xhtml:div">
<xsl:if test="position() = 1">
<key><xsl:text>title</xsl:text></key>
<string><xsl:value-of select="xhtml:a/xhtml:span"/></string>
</xsl:if>
<xsl:if test="position() = 2">
<key><xsl:text>snippet</xsl:text></key>
<string><xsl:value-of select="xhtml:a"/></string>
</xsl:if>
</xsl:for-each>
</dict>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment