From a45daba90232e2a2fda0966179fa56755566d290 Mon Sep 17 00:00:00 2001 From: Rylen Anil Date: Sun, 26 Jul 2026 05:04:33 +0000 Subject: [PATCH] docs: mention Ndiff Python parser usage --- ndiff/README | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ndiff/README b/ndiff/README index a2277f349..79d116045 100644 --- a/ndiff/README +++ b/ndiff/README @@ -13,6 +13,23 @@ without installing it. Use "ndiff --help" for usage instructions. +Using Ndiff as a Python XML parser +---------------------------------- + +Ndiff also installs as the Python module `ndiff`. Programs that need to +read Nmap XML can import the module and load a scan with the same parser +used by the `ndiff` command: + + from ndiff import Scan + + scan = Scan() + scan.load_from_file("scan.xml") + for host in scan.hosts: + print(host.get_id(), host.state) + +The `Scan` object contains parsed hosts, ports, hostnames, OS matches, +and pre- and post-scan script results from the input Nmap XML file. + Here is a sample of the output: $ ./ndiff test-scans/random-1.xml test-scans/random-2.xml