我的目标是通过xsl从KeyPass(2.x)xml格式中提取特定密钥。
KeyPass XML如下所示:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<KeePassFile>
<Meta>
<Generator>KeePass</Generator>
</Meta>
<Root>
<Group>
<UUID>NqDrFtUxs0SiwVPehBpONg==</UUID>
<Name>ExampleDatabase</Name>
<Entry>
<String>
<Key>Notes</Key>
<Value>Notes</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">Password</Value>
</String>
<String>
<Key>Title</Key>
<Value>Sample Entry</Value>
</String>
<String>
<Key>URL</Key>
<Value>http://keepass.info/</Value>
</String>
<String>
<Key>UserName</Key>
<Value>User Name</Value>
</String>
</Entry>
<Entry>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">12345</Value>
</String>
<String>
<Key>Title</Key>
<Value>Sample Entry #2</Value>
</String>
<String>
<Key>URL</Key>
<Value>http://keepass.info/help/kb/testform.html</Value>
</String>
<String>
<Key>UserName</Key>
<Value>Michael321</Value>
</String>
</Entry>
<Group>
<UUID>mec/n7Hkf0uZMDMrZyaO7A==</UUID>
<Name>General</Name>
</Group>
<Group>
<UUID>mBKJFmgV6UOQQmXlmhZt/A==</UUID>
<Name>Windows</Name>
</Group>
<Group>
<UUID>CKbqJW0RwUKdUT/go0EnJg==</UUID>
<Name>Network</Name>
</Group>
<Group>
<UUID>B6yKdAooSkOj6+uvrGDURQ==</UUID>
<Name>Internet</Name>
</Group>
<Group>
<UUID>4IG7YyeaY0yHbnuUtJMx5A==</UUID>
<Name>eMail</Name>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">1.Os0mnyE6ESeL1yGnTsX6</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry1</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>Some@Email.com</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">Os0mnyE6ESeL1yGnTsX6</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry1</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>FirsteMail@Adress.com</Value>
</String>
</Entry>
</History>
</Entry>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">2.RlYOCgZDirnjbjcu8Td2</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry2</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>SecondeMail@Adress.com</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Login für den Plesk Server.</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">RlYOCgZDirnjbjcu8Td2</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry2</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>Adress@Bla.com</Value>
</String>
</Entry>
</History>
</Entry>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">3.RzJsbTeK29MS1GnUiTlb</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry3</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>ThirdeMail@Adress.com</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">RzJsbTeK29MS1GnUiTlb</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry3</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>ThirdeMail@Adress.com</Value>
</String>
</Entry>
</History>
</Entry>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">4.8BONlQkfKRHpPdTL3luh</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry4</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>eMail@Adress.com</Value>
</String>
<History>
<Entry>
<String>
<Key>Notes</Key>
<Value>Some Note</Value>
</String>
<String>
<Key>Password</Key>
<Value ProtectInMemory="True">8BONlQkfKRHpPdTL3luh</Value>
</String>
<String>
<Key>Title</Key>
<Value>Entry4</Value>
</String>
<String>
<Key>URL</Key>
<Value />
</String>
<String>
<Key>UserName</Key>
<Value>eMail@Adress.com</Value>
</String>
</Entry>
</History>
</Entry>
</Group>
<Group>
<UUID>A/OASMueGE+ZBzEpvrTjow==</UUID>
<Name>Homebanking</Name>
</Group>
</Group>
<DeletedObjects />
</Root>
</KeePassFile>
我想要访问单个&#39; Value&#39;标签。例如,组别电子邮件在Kategory标题或密码中的价值。那么该值将是(eMail / Title :)&#39; Entry1&#39;。我只需要xsl来收集KeePass.xml的信息。
答案 0 :(得分:0)
我认为您的意思是UserName
密钥,该密钥在Group
中出现四次,在每个子Entry
中出现一次。在这种情况下,您需要选择第三个Entry
以获取第三封电子邮件。在您的代码中,您可以使用Entry
的位置谓词来实现该目标:
<xsl:for-each select="./Entry[3]/String">
<xsl:if test="Key='UserName'">
<xsl:value-of select="Value"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
答案 1 :(得分:0)
我目前的解决方案是:
<xsl:for-each select="KeePassFile/Root/Group/Group[child::Name='eMail']/Entry[1]/String[Key='UserName']">
<td><xsl:value-of select="Value"/></td>
</xsl:for-each>