XMLLINT(1)
๐ XMLLINT(1) โ the xmllint manual, bestie edition ๐
okay so welcome to xmllint, from the xmllint Manual (that's the manual name, keep it in your notes ๐). it's a command line XML tool and honestly? it's giving main character energy for anyone who lives in a terminal and also lives in XML files. we're doing this in parts because there's a LOT, so buckle up ๐
โจ NAME โจ
xmllint โ command line XML tool. that's the whole vibe. one job, many flags. ๐
๐ฆ SYNOPSIS ๐ฆ
xmllint [--version | --debug | --quiet | --shell |
--xpath "XPath_expression" | --xpath0 "XPath_expression" |
--copy | --recover | --huge | --nocompact | --nodefdtd |
--nodict | --noenc | --noent | --nofixup-base-uris | --noout |
--nonet | --path "PATH(S)" | --load-trace | --valid |
--postvalid | --dtdvalid URL | --dtdvalidfpi FPI | --timing |
--output FILE | --repeat | --insert | --strict-namespace |
--compress | --html | --xmlout | --push | --memory |
--max-ampl INTEGER | --maxmem NBBYTES | --nowarning | --noblanks
| --nocdata | --format | --pretty INTEGER | --encode ENCODING |
--dropdtd | --nsclean | --catalogs | --nocatalogs | --auto |
--xinclude | --noxincludenode | --loaddtd | --dtdattr | --stream
| --walker | --pattern PATTERNVALUE | --relaxng SCHEMA |
--schema SCHEMA | --schematron SCHEMA | --c14n | --c14n11 |
--exc-c14n | --pedantic | --sax | --sax1 | --oldxml10]
{XML-FILE(S)... | -}
likeโฆ look at all those flags. no cap, she's got options. ๐
๐ธ DESCRIPTION ๐ธ
so xmllint parses one or more XML files, and you hand them over on the command line as XML-FILE โ or, if the filename you provide is -, she'll just read from standard input instead. slay, stdin rep ๐
she prints various types of output depending on which options you picked, and she's genuinely useful for detecting errors both in XML code and in the XML parser itself. like a little error-detecting bestie. ๐
and for the record: xmllint is part of the libxml2 library. iykyk. ๐
โ VALIDATION OPTIONS โ
these are the options that enable validation. vibe check your documents, fr fr.
--dtdvalid URLโ validate using the DTD that lives at an URL. go fetch, bestie ๐ซถ--dtdvalidfpi FPIโ validate using the DTD identified by a Formal Public Identifier FPI. heads up though: this needs a catalog that exports that Formal Public Identifier, otherwise it simply won't work. no catalog, no service ๐--relaxng SCHEMAโ validate using the RelaxNG file named SCHEMA.--schema SCHEMAโ validate using the W3C XML Schema file named SCHEMA.--schematron SCHEMAโ validate using the Schematron file named SCHEMA.--validโ figures out if the document is a valid instance of the Document Type Definition (DTD) it includes. you can also point at a DTD to validate against straight from the command line with the--dtdvalidoption. and by default,xmllintalso checks whether the document is well-formed. she's thorough like that. ๐--strict-namespaceโ throws an error if the document is well-formed but has namespace errors. this one enforces namespace-well-formedness. strict queen. ๐
๐ง PARSER OPTIONS ๐ง
these set the respective parser options. one bullet each, no skipping, promise ๐ค
--dtdattrโ fetch the external DTD and populate the tree with inherited attributes. this one implies--loaddtd.--hugeโ ignore some hardcoded parser limits. big girl energy ๐ฅ--loaddtdโ fetch an external DTD and external parameter entities.--max-ampl INTEGERโ sets the maximum amplification factor, which is what protects you against exponential entity expansion (aka the "billion laughs" attack ๐ญ). the default value is5. documents that make heavy use of entity expansion may need a higher value.--noblanksโ drops "ignorable" blank spaces. and bestie, listen: this option is unreliable and shouldn't be used. not me warning you twice. ๐--nocatalogsโ do not use any catalogs.--nocdataโ substitute CDATA sections with equivalent text nodes.--nodefdtdโ do not set the default HTML doctype (parser optionHTML_PARSE_NODEFDTD).--noencโ ignore the encoding declaration (parser optionXML_PARSE_IGNORE_ENC).--noentโ substitute entity values in place of entity references. by defaultxmllintleaves entity references in place. this option enables loading of external DTDs and entities.--nofixup-base-urisโ don't fixxml:baseURIs when processing XIncludes (parser optionXML_PARSE_NOBASEFIX).--nonetโ do not use the Internet to fetch DTDs or entities. heads up: this has no effect with libxml2 2.15 or later.--nowarningโ do not emit warnings from the parser and/or validator. (we love a quiet queen but you might miss stuff ๐)--nscleanโ remove redundant namespace declarations.--oldxml10โ use deprecated parsing rules from before XML 1.0, 5th edition.--pedanticโ enable additional warnings. she's watching ๐--recoverโ output any parsable portions of an invalid document. exact behavior is unspecified, and use of this option is discouraged. seriously, proceed with caution bestie.--xincludeโ do XInclude processing.
๐ MISCELLANEOUS OPTIONS ๐
the options that don't fit in any other category. the little weirdos. we stan. ๐ซถ
--catalogsโ use the SGML catalog(s) fromSGML_CATALOG_FILES. note that XML catalogs are loaded by default.--dropdtdโ remove the DTD after parsing. bye bye ๐--htmlโ use the HTML parser.--path "PATH(S)"โ use the (space- or colon-separated) list of filesystem paths given by PATHS to load DTDs or entities. if your list is space-separated, wrap it in quotation marks or she will simply not understand you. ๐--quietโ don't print informational messages tostderr. peace and quiet, periodt.--saxโ print SAX callbacks for debugging. you can also use it for streaming DTD and Schema validation when you pair it with--noout.--shellโ run a navigating shell. the details on the commands available in shell mode are further down (see the section called โSHELL COMMANDSโ). interactive era โจ--streamโ use the streaming API. super useful when combined with the--relaxngor--validoptions for validating files that are too large to be held in memory. big file, small RAM, no problem.--versionโ display the version of libxml2 used.
๐ OUTPUT OPTIONS ๐
these control output. important caveat: except for --noout, these have no effect in SAX or stream mode. remember that fr fr.
--compressโ turn ongzip(1)compression of output.--c14n,--c14n11,--exc-c14nโ use the W3C XML Canonicalisation (C14N) to serialize the result of parsing tostdout. it keeps comments in the result.--encode ENCODINGโ output in the given encoding. note that this works for a full document, not for fragments or results from XPath queries.--formatโ reformat and reindent the output. theXMLLINT_INDENTenvironment variable controls the indentation, and the default value is two spaces (" ").
real talk: especially when there's no DTD, this feature has never worked reliably and is fundamentally broken. iconic behaviour, honestly. ๐
--nooutโ suppress output. by default,xmllintoutputs the result tree.--output FILEโ define a file path wherexmllintwill save the result of parsing. usually the programs build a tree and save it onstdout; with this option, the resulting XML instance gets saved onto a file instead. โจ--pretty INTEGERโ value0means no formatting,1meansXML_SAVE_FORMAT(same as--format), and2meansXML_SAVE_WSNONSIG.--xmloutโ used together with--html. normally when HTML is parsed the document is saved with the HTML serializer, but with this option the resulting document is saved with the XML serializer instead. it's primarily used to generate XHTML from HTML input. glow-up pipeline ๐
๐ฅ DEBUG OPTIONS ๐ฅ
these ones let you debug the libxml2 library itself. but listen: the behavior of these options may change without notice. no promises, no cap.
--autoโ generate a small document for testing purposes.--copyโ test the internal copy implementation.--debugโ parse a file and output an annotated tree of the in-memory version of the document. ๐ณ--insertโ test for valid insertions. DEPRECATED: this feature will be removed. rip bestie ๐ชฆ--load-traceโ display all the documents loaded during processing, tostderr.--maxmem NNBYTESโ test the parser memory support. NNBYTES is the maximum number of bytes the library is allowed to allocate. you can also use this to make sure that batch processing XML files won't exhaust the virtual memory of the server running them. protect the server, protect the vibe ๐ก๏ธ--memoryโ parse from memory.--nocompactโ do not generate compact text nodes (parser optionXML_PARSE_COMPACT). only for debugging.--nodictโ don't use dictionaries (parser optionXML_PARSE_NODICT). only for debugging.--noxincludenodeโ do XInclude processing, but don't generate XInclude start and end nodes.--pattern PATTERNVALUEโ used to exercise the pattern recognition engine, which can be used with the reader interface to the parser. it lets you select some nodes in the document based on an XPath (subset) expression. used for debugging.--postvalidโ validate after parsing has completed. late validation, still valid ๐--pushโ use the push mode of the parser.--repeatโ repeat100times, for timing or profiling. girl is doing reps ๐๏ธ--sax1โ use the deprecated SAX1 interface (only for debugging).--timingโ output information about how long it takesxmllintto perform the various steps. โฑ๏ธ--walkerโ test the walker module, which is a reader interface but for a document tree: instead of using the reader API on an unparsed document, it works on an existing in-memory tree. used for debugging.--xpath "XPath_expression"โ run the XPath expression given as the argument and print the result. if the result is a nodeset, every node in the node set is serialized in full in the output. and if the node set is empty, you'll get the"XPath set is empty"result and exit code 11 will be returned.. (yes, that's a double period, i'm just being faithful ๐ญ)
๐ SHELL COMMANDS ๐
so xmllint offers an interactive shell mode, which you invoke with the --shell command. the commands available in shell mode include (in alphabetical order, because we're organized like that โจ):
baseโ display the XML base of the node.byeโ leave the shell. ๐cat NODEโ display the given node, or the current one.cd PATHโ change the current node to the given path (if it's unique), or to the root if no argument is given.dir PATHโ dumps information about the node (namespace, attributes, content).du PATHโ show the structure of the subtree under the given path, or under the current node.exitโ leave the shell.helpโ show this help. ๐load FILENAMEโ load a new document with the given filename.ls PATHโ list the contents of the given path or the current directory.pwdโ display the path to the current node.quitโ leave the shell.save FILENAMEโ save the current document to the given filename, or to the original name.validateโ check the document for errors.write FILENAMEโ write the current node to the given filename.
and that's part 1, bestie โ there's more coming, so don't go anywhere ๐
๐ฟ ENVIRONMENT (aka the vibes your shell passes down to me) ๐ฟ
okay so bestie, before we even get to the exit codes, lemme tell you about the environment variables, because these are the little knobs your shell can turn to change how I behave. no cap, they're lowkey important.
SGML_CATALOG_FILESโ so you can change how SGML catalog behavior works by redirecting queries to your own set of catalogs ๐. how? set this variable to a list of catalogs, that's it, that's the whole move. and listen: an empty one should deactivate loading the default catalog. yes, empty. periodt.XML_CATALOG_FILESโ same energy, but for XML catalogs โจ. set it to a space-separated list of catalogs to redirect queries to your own set. and because spaces are the separator, use percent-encoding to escape spaces or other characters (iykyk). an empty variable should deactivate loading the default catalog, same as above ๐ .XML_DEBUG_CATALOGโ want the tea on what the catalogs are doing?? set this to non-zero using theexportcommand and I'll output debugging information related to catalog operations ๐. not me being nosy, it's a feature.XMLLINT_INDENTโ this one controls the indentation ๐. the default value is two spaces" ". that's it. that's the whole default. iconic.
๐ DIAGNOSTICS (the return codes, aka my receipts) ๐
my return codes give you info you can actually use when you're calling me from scripts. so like, if statements and && chains and all that main character shell scripting energy ๐ซถ.
here's the full rundown, no skips, no summarising, we go all the way down:
0โ No error ๐. we ate, literally nothing went wrong.1โ Unclassified ๐ญ. it's giving "something happened and we're not putting a label on it".2โ Error in DTD ๐.3โ Validation error ๐.4โ Document isn't well-formed or couldn't be read ๐ญ. two for one, tragic either way.5โ Error in schema compilation ๐ง.6โ Error writing output โ๏ธ.7โ Error in pattern (generated when--patternoption is used) ๐ธ.9โ Out of memory error ๐. oh she's struggling.10โ XPath evaluation error ๐ฅ.11โ XPath result is empty ๐ณ๏ธ.
bestie there is literally no 8 in this list. I'm not hiding it from you, it's just not here. don't come for me about it, I didn't write the numbers ๐
.
๐ SEE ALSO
more information can be found in the libxml2 repo at https://gitlab.gnome.org/GNOME/libxml2 โ go forth and read, it's right there, go get your education ๐ฆ.
๐ AUTHORS (the legends, the icons, the moment)
- John Fleck
<jfleck@inkstain.net> - Ziying Sherwin
<sherwin@nlm.nih.gov> - Heiko Rupp
<hwr@pilhuhn.de>
three whole humans made this happen and we're obsessed with them fr fr ๐.
๐ COPYRIGHT
Copyright ยฉ 2001, 2004
and that's the whole page, bestie!! ๐ซถ this was xmllint, and it's hanging out at version/date 09/04/2026 in XMLLINT(1). go forth, validate things, read your exit codes, and remember: an empty catalog variable deactivates the default catalog, and no I will not stop bringing it up โจ๐ธ๐
๐ฆ where this page comes from
- arch rolling: libxml2 2.15.4-1 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms