KeePass   KeePass Help Center Home KeePass Home | Package Downloads | Flag Translations | Blocks Plugins | Donate Donate  
Home Help Center Home | People Forums | Award Awards | Link Links | Search Search  







People

XML Replace


About the XML replacement functionality.

Help  General Information

XML Replace is a powerful feature that modifies a database by manipulating its XML representation.

KeePass creates a KDBX XML DOM of the current database in memory, performs the operation specified by the user (e.g. remove nodes or replace text), tries to load the modified XML, and merges the current database with the modified database.

Warning This is a feature for experts. Use with caution!

A few links that might be helpful for working with XPath and regular expressions:

KeePass protects history entries; XML Replace cannot be used to modify these. Furthermore, any changes to database properties (database name/description, etc.) may be ignored.


Help  Usage Examples


Replace text in all entry titles and notes
Select nodes: //Entry/String[Key='Title' or Key='Notes']/Value
Action:Replace data
Data:Inner text
Find what:TheTextToFind
Replace with:TheReplacement
Within all entry titles and notes, this replaces all occurences of TheTextToFind by TheReplacement.

Replace all HTTP URLs by HTTPS URLs
Select nodes: //Entry/String[Key='URL']/Value
Action:Replace data
Data:Inner text
Find what:^http:
Replace with:https:
Regular expressions:Activated
Within all entry URL fields, this replaces all HTTP URLs by HTTPS URLs.

Replace group icons
Select nodes: //Group/IconID
Action:Replace data
Data:Inner text
Find what:^48$
Replace with:36
Regular expressions:Activated
This assigns the ZIP package icon to all groups that currently have a closed folder as icon.

All icon IDs can be found in the icon picker dialog.

Delete entry strings by name
Select nodes: //Entry/String[Key='TheName']
Action:Remove nodes
Removes all entry strings named TheName.

Delete entry attachments by name extension
Select nodes: //Entry/Binary[substring(Key, string-length(Key) - 3) = '.jpg']
Action:Remove nodes
Removes all entry attachments that have a name ending in '.jpg'.

The '3' in the node selection XPath expression is the length of '.jpg' - 1. If you'd e.g. want to search for attachments that have a name ending in '.abcde', you'd need to replace the '3' by '5'.

Reset background colors
Select nodes: //Entry/BackgroundColor
Action:Remove nodes
Sets the background color of all entries to the default (transparent/alternating).

Disable auto-type for entries with empty fields
Select nodes: //Entry/String[(Key='UserName' or Key='Password') and Value='']/../AutoType/Enabled
Action:Replace data
Data:Inner text
Find what:True
Replace with:False
Disables auto-type for all entries that have an empty user name field or an empty password field.

Convert {DELAY= to upper-case
Select nodes: //DefaultSequence | //KeystrokeSequence
Action:Replace data
Data:Inner text
Find what:{DELAY=
Replace with:{DELAY=
Converts all {DELAY= codes within auto-type sequence overrides and associations to upper-case (by default the case sensitivity option is turned off, thus the 'Find what' text matches all cases).

In KeePass 2.x, placeholders are case-insensitive. However, this XML Replace operation may be useful as preparation for the following example (which matches {DELAY= in a case-sensitive way).

Prepend {DELAY=50} to all sequences without a {DELAY=
Select nodes: (//DefaultSequence | //KeystrokeSequence)[not(contains(., '{DELAY=')) and (. != '')]
Action:Replace data
Data:Inner text
Find what:^(.*)$
Replace with:{DELAY=50}$1
Regular expressions:Activated
Prepends a {DELAY=50} to all auto-type sequence overrides and associations that do not contain any {DELAY= already and are not empty.

Note that the node selection is case-sensitive (independent of the data case sensitivity option), thus you need to ensure that all {DELAY= codes are upper-case before performing this operation. This can e.g. be done using the XML Replace operation mentioned above.

Change {DELAY= values
Select nodes: //DefaultSequence | //KeystrokeSequence
Action:Replace data
Data:Inner text
Find what:\{DELAY=[\d\s]*\}
Replace with:{DELAY=50}
Regular expressions:Activated
Sets the values of all {DELAY= codes within auto-type sequence overrides and associations to 50.

Remove {DELAY=x} from all sequences
Select nodes: //DefaultSequence | //KeystrokeSequence
Action:Replace data
Data:Inner text
Find what:\{DELAY=[\d\s]*\}
Replace with:(Leave empty)
Regular expressions:Activated
Removes all {DELAY=x} codes from all auto-type sequences.

Reset default sequences that contain {DELAY=
Select nodes: //DefaultSequence[contains(., '{DELAY=')]
Action:Remove nodes
If a sequence has been specified in the field 'Override default sequence' (in the entry dialog) and it contains {DELAY=, the sequence is reset, i.e. the option 'Inherit default auto-type sequence from group' is activated.

Add an auto-type association to all entries
Select nodes: //Entry/AutoType
Action:Replace data
Data:Outer XML
Find what:</AutoType>\Z
Replace with:<Association><Window>* - Notepad</Window><KeystrokeSequence>{PASSWORD}</KeystrokeSequence></Association></AutoType>
Regular expressions:Activated
Adds an auto-type association to all entries: the window title '* - Notepad' is associated with the sequence '{PASSWORD}'.








Valid XHTML 1.0 Transitional Document

Get KeePass

Flattr this


KeePass is OSI Certified Open Source Software
Copyright © 2003-2014
Dominik Reichl, [Legal Contact / Imprint] [Disclaimer] [Acknowledgements] [Donate], Downloads hosted at

Get KeePass Password Safe at
SourceForge.net. Fast, secure and Free Open Source software downloads