Sample Header Ad - 728x90

Unable to extract some properties from Maven settings.xml using either xmllint or xmlstarlet

0 votes
1 answer
57 views
I have a Maven settings file at ~/.m2/settings.xml. I need to write some scripting that extracts the username and password from one of the server entries. I've tried using both "xmllint" and "xmlstarlet" using what I believe are the correct (different) command-line parameters for both of those. The result for both is just an empty string. There is no error, it just prints nothing. This is an excerpt of ~/.m2/settings.xml:
central
					...
					...
		
	...
This is working fine with Maven. For xmllint, I'm trying the following:
xmllint --xpath 'string(//server[id="central"]/username/text())' ~/.m2/settings.xml
For xmlstarlet, it is this:
xmlstarlet sel -T -R -D -t -v "//settings/servers/server[id='central']/username/text()" ~/.m2/settings.xml
Those are slightly semantically different, but I've tried several variations. All of these just print an empty string.
Asked by David M. Karr (1173 rep)
Sep 26, 2024, 08:58 PM
Last activity: Sep 26, 2024, 09:09 PM