Get information from xml file

I am trying to get information from an xml file on all our machines. I want to return these in a format that is readable and exportable to say excel.

I am mainly concerned with to areas of that xml file.

Here is the location and filename
C:\ProgramData\VPN\preferences_global.xml

Here are the lines I would really like to grab the info from but am ok with the whole file contents if need be.

vpn.vpn.com
1.1.1.1

Any help with this would be greatly appreciated. Thanks.

I forgot to add that I would also like an option to maybe have it skip ones that have certain DefaultHostname and DefaultHostadresses in there.

It might help to have some additional information about the XML file itself.
You list the values you are looking for, but nothing about the Notes that hold the values.

This might get you started.

node names of child nodes of select "*" of xml document of file "C:\Some.xml"

Ok trying to paste it in here to show you but looks like garbage. Any suggestions?

I’m pasting in some XML data from an XML file on my system. Once I have it “pasted in”, I select the XML content and click the “</>” button in the top bar.

<?xml version="1.0" encoding="utf-8"?>
<unattend>
	<settings pass="offlineServicing">
		<component name="Microsoft-Windows-Audio-AudioCore" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
			<Start_AudioSrv>2</Start_AudioSrv>
			<Start_EndpointBuilder>2</Start_EndpointBuilder>
		</component>
		<component name="Microsoft-Windows-Audio-AudioCore" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
			<Start_AudioSrv>2</Start_AudioSrv>
			<Start_EndpointBuilder>2</Start_EndpointBuilder>
		</component>
indent preformatted text by 4 spaces
<?xml version="1.0" encoding="UTF-8"?>
<AnyConnectPreferences>
<DefaultUser/> <DefaultSecondUser/> 
<ClientCertificateThumbprint/> 
<ServerCertificateThumbprint/> 
<DefaultHostName>vpn.vpn.com</DefaultHostName
<DefaultHostAddress>1.1.1.1</DefaultHostAddress>
<DefaultGroup/> 
<ProxyHost/>
<ProxyPort/>
<SDITokenType>none</SDITokenType>
<ControllablePreferences/> 
</AnyConnectPreferences>

Is there a way to get just the DefaultHostName and DefaultHostAddress?

Maybe even take a step further and say on return ones and their values that are not say vpn.vpn.com and 1.1.1.1. I will want to run this against all our machines.

maybe this topic Help navigating through and selecting information from an XML document might help

1 Like

Try this:

node values of xpaths "/AnyConnectPreferences/DefaultHostName/text()" of xml documents of files "C:\ProgramData\VPN\preferences_global.xml"

I wasn’t able to test it, but that should be correct.

1 Like

In case others aren’t aware, the XML inspector is not available on OS X clients. Which is a huge shame that feature parity is lacking across platforms for something as universal as XML.

1 Like

I was told that XML inspectors are coming on the Mac side at the user group meeting. I won’t hold my breath, but at least that is some progress.

1 Like