XPath command

Got a problem you cannot solve? Try here.
mdavtec
Posts: 27
Joined: Wed Jan 20, 2016 2:59 pm

XPath command

Postby mdavtec » Tue Jul 21, 2020 6:03 pm

Is it possible to get value of 'Password" which is 'P@ssword1' from this XML text using XPath command? I was able to get the entire string using following command:
Evaluate Query //configuration/connectionStrings/add[@name="UDS"] on XML file $PROGRAMDATAFOLDER$\Web\Web.config, get result into variable UDSAppPWD as type Full XML String

Wonder if there is a better way to get password value.



<configSections>
<connectionStrings>
<clear />
<add name="UDS" connectionString="Server=localhost\DataED;Database=UDS;User Id=UDS_App;Password=P@ssword1" providerName="System.Data.SqlClient" />
<add name="UDSEntities" connectionString="metadata=res://*/SmsModel.csdl|res://*/SmsModel.ssdl|res://*/SmsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Server=localhost\DataED;Database=UDS;User Id=UDS_App;Password=P@ssword1;&quot;" providerName="System.Data.EntityClient" />
<add name="UDSAdmin" connectionString="Server=localhost\DataED;Database=UDS;User Id=UDS_Admin;Password=P@ssword1" providerName="System.Data.SqlClient" />
<!-- Used by ASP.NET Identity -->

</connectionStrings>
...
</configSections>
ExchA

FrancescoT
Site Admin
Posts: 5360
Joined: Sun Aug 22, 2010 4:28 am

Re: XPath command

Postby FrancescoT » Wed Jul 22, 2020 12:02 pm

You may use the following query in combination with "Result Type= Node Value":
//configSections/connectionStrings/add[@name="UDS"]/@connectionString

This will restrict the returned value to:
"Server=localhost\DataED;Database=UDS;User Id=UDS_App;Password=P@ssword1"

But you can't get just the password, because there isn't any password value. Password is part of value assigned with "connectionString".
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: Google [Bot] and 53 guests