If you're using MSBuild 4.0 or above...... use (built in) Xml Peek.
If you're using pre 4.0, use XmlRead from Ms Build community task.
https://github.com/loresoft/msbuildtasks
Here is a ~Peek Example:
<Target Name="ReadXmlPeekValue">
<!-- you do not need a namespace for this example, but I left it in for future reference -->
<XmlPeek Namespaces="<Namespace Prefix='peanutNamespace' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/>"
XmlInputPath=".\Parameters.xml"
Query="/parameters/setParameter[@name='MyConnectionStringParameter']/@value">
<Output TaskParameter="Result" ItemName="Peeked" />
</XmlPeek>
<Message Text="@(Peeked)"/>
<XmlPeek Namespaces="<Namespace Prefix='peanutNamespace' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/>"
XmlInputPath=".\Parameters.xml"
Query="/parameters/setParameter[@name='MyConnectionStringParameter']/@value">
<Output TaskParameter="Result" PropertyName="PeekedSingle" />
</XmlPeek>
<Message Text="$(PeekedSingle)"/>
</Target>
If you need a namespace, note the XML namespace must be HTML-encoded.
Example based on this simple one: ((also shows XmlPoke))
http://yentran.org/blog/2012/05/11/modifying-config-file-in-an-msbuild-project/
When using "Peek", even with msbuild.exe (from %WINDIR%\Microsoft.NET\Framework\v4.0.30319), you must specify the ToolsVersion.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >