Read your first saved site
Install one package, save a small XML fixture, then list, select and search its metadata. This example needs no FileZilla installation or server account, loads no passwords and opens no connection.
Install
npm init -y
npm install @jalsoedesign/filezilla-coreUse a supported Node.js runtime. TypeScript is the default; language setup explains JavaScript, MJS and CommonJS.
Save sitemanager.xml
Save this file in the host working directory, or download the fixture. It contains one synthetic site named Demo. The loopback address is metadata only; this program never connects to it.
<FileZilla3>
<Servers>
<Server>
<Host>127.0.0.1</Host>
<Port>22</Port>
<Protocol>1</Protocol>
<Type>0</Type>
<User>deploy</User>
<Logontype>2</Logontype>
<Name>Demo</Name>
</Server>
</Servers>
</FileZilla3>Save and run the reader
Save read-sites.ts by default, or the filename in the selected language tab. Download: TypeScript · JavaScript · MJS · CommonJS
// read-sites.ts
import {getSiteManager} from '@jalsoedesign/filezilla-core';
const [filename = './sitemanager.xml'] = process.argv.slice(2);
const manager = getSiteManager(filename, {includePasswords: false});
for (const site of manager.getServers()) {
console.log(JSON.stringify({
path: site.path,
host: site.properties.host,
protocol: site.siteProtocolName,
}));
}
const selected = manager.getServerByPath('Demo');
if (!selected) {
throw new Error('The Demo site is unavailable.');
}
console.log('Exact selection:', selected.path);
console.log('Host matches:', manager.searchServers('127.0.0.1', {fields: 'all'}).length);
console.log('Metadata only; no remote connection.');// read-sites.js
import {getSiteManager} from '@jalsoedesign/filezilla-core';
const [filename = './sitemanager.xml'] = process.argv.slice(2);
const manager = getSiteManager(filename, {includePasswords: false});
for (const site of manager.getServers()) {
console.log(JSON.stringify({
path: site.path,
host: site.properties.host,
protocol: site.siteProtocolName,
}));
}
const selected = manager.getServerByPath('Demo');
if (!selected) {
throw new Error('The Demo site is unavailable.');
}
console.log('Exact selection:', selected.path);
console.log('Host matches:', manager.searchServers('127.0.0.1', {fields: 'all'}).length);
console.log('Metadata only; no remote connection.');// read-sites.mjs
import {getSiteManager} from '@jalsoedesign/filezilla-core';
const [filename = './sitemanager.xml'] = process.argv.slice(2);
const manager = getSiteManager(filename, {includePasswords: false});
for (const site of manager.getServers()) {
console.log(JSON.stringify({
path: site.path,
host: site.properties.host,
protocol: site.siteProtocolName,
}));
}
const selected = manager.getServerByPath('Demo');
if (!selected) {
throw new Error('The Demo site is unavailable.');
}
console.log('Exact selection:', selected.path);
console.log('Host matches:', manager.searchServers('127.0.0.1', {fields: 'all'}).length);
console.log('Metadata only; no remote connection.');// read-sites.cjs
const {getSiteManager} = require('@jalsoedesign/filezilla-core');
async function main() {
const [filename = './sitemanager.xml'] = process.argv.slice(2);
const manager = getSiteManager(filename, {includePasswords: false});
for (const site of manager.getServers()) {
console.log(JSON.stringify({
path: site.path,
host: site.properties.host,
protocol: site.siteProtocolName,
}));
}
const selected = manager.getServerByPath('Demo');
if (!selected) {
throw new Error('The Demo site is unavailable.');
}
console.log('Exact selection:', selected.path);
console.log('Host matches:', manager.searchServers('127.0.0.1', {fields: 'all'}).length);
console.log('Metadata only; no remote connection.');
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});Run
npm install --save-dev typescript tsx @types/node
npm pkg set type=module
npx tsx read-sites.ts ./sitemanager.xmlnpm pkg set type=module
node read-sites.js ./sitemanager.xmlnode read-sites.mjs ./sitemanager.xmlnode read-sites.cjs ./sitemanager.xmlOutput
{"path":"Demo","host":"127.0.0.1","protocol":"SFTP"}
Exact selection: Demo
Host matches: 1
Metadata only; no remote connection.The methods return objects and arrays; the example explicitly prints this metadata. No filesystem setup code is needed in the program because the input file was saved above.
Use an existing Site Manager file
Pass the selected XML filename in place of ./sitemanager.xml, then choose a path returned by manager.getServers() instead of Demo. Exact selection is case-sensitive; search can return multiple sites. Read credential loading before opting into saved passwords.
If it fails
| Symptom | Next step |
|---|---|
| File not found | Run from the directory containing the fixture or pass its explicit path. |
| Demo unavailable | Use the fixture above or select a canonical path actually returned by the file. |
| Invalid XML or field | Follow validation and import diagnostics. |
Next: query recipes, import diagnostics, normalized profiles, or connect a saved site.